Professional Web Applications Themes

should I use join? - MySQL

Hi I am stumped on a select statement. basically I have 2 tables I want to use in my select table1 = "uploads" has fields 'id', 'size' table 2 = "uploadOwners" has field 'id' which is a foreign key referencing uploads.id, and field 'owner' "uploads" +-----+------------+ | id | size | +-----+------------+ | 1 | 653636 | | 2 | 45674 | | 3 | 5678 | +-----+------------+ "uploadsOwners" +-----+------------+ | id | owner | +-----+------------+ | 1 | bill | | 2 | john | | 3 | john | +-----+------------+ basically, I only want to select entries from ...

  1. #1

    Default should I use join?

    Hi

    I am stumped on a select statement. basically I have 2 tables I want
    to use in my select

    table1 = "uploads" has fields 'id', 'size'

    table 2 = "uploadOwners" has field 'id' which is a foreign key
    referencing uploads.id, and field 'owner'

    "uploads"
    +-----+------------+
    | id | size |
    +-----+------------+
    | 1 | 653636 |
    | 2 | 45674 |
    | 3 | 5678 |
    +-----+------------+


    "uploadsOwners"
    +-----+------------+
    | id | owner |
    +-----+------------+
    | 1 | bill |
    | 2 | john |
    | 3 | john |
    +-----+------------+

    basically, I only want to select entries from "uploads" that are
    referenced to uploadOwners.owner="john"

    I am at a loss for the proper syntax



    Mike Cardeiro

    mcardeiro@yahoo.com Guest

  2. #2

    Default Re: should I use join?

    com wrote: 

    You might not want a join per se (that requires some
    ForeignKey Kung-fu) - but rather a compound select.
    Sanders Guest

  3. #3

    Default Re: should I use join?

    com wrote: 


    How about something like:

    SELECT * FROM uploads
    JOIN uploadsOwners ON uploads.id = uploadsOwners.id
    WHERE uploadsOwners.owner = 'john';

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  4. #4

    Default Re: should I use join?

    Jerry Stuckle wrote:
     

    Does that require Foreign Key relationship?
    Sanders Guest

  5. #5

    Default Re: should I use join?

    Sanders Kaufman wrote: 
    >
    >
    > Does that require Foreign Key relationship?[/ref]

    No, joins do not require a foreign key relationship. Foreign keys are
    strictly for DELETE statements or UPDATE statements where the key is
    being changed.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

Similar Threads

  1. Is left-join faster then inner join?
    By howachen@gmail.com in forum MySQL
    Replies: 5
    Last Post: March 5th, 07:11 AM
  2. FMS Join two flv...
    By Luiz Alberto in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: November 23rd, 02:51 PM
  3. Join
    By Maarten in forum ASP Database
    Replies: 3
    Last Post: November 1st, 06:07 AM
  4. Replies: 2
    Last Post: September 18th, 09:59 PM
  5. Select Left Join AND Right Join
    By David in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 15th, 03:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139