Results 1 to 3 of 3
  1. #1

    Question MySQL query question.

    I have a table like this in MySQL:

    eid sid
    . .
    12 49
    13 51
    13 78
    14 12
    14 38
    14 78
    17 91
    16 78
    21 13
    21 51
    .

    Now i want to select all the eid's that their sid is (( 38 AND also 78 ))
    (in this example like: 14) what do you think i should use for query string?
    Professional Logo Design.
    For more information please visit our site

  2. #2
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,104
    SELECT UNIQUE eid FROM table WHERE sid = 78 OR sid = 38 GROUP BY eid;

    I think that will work, but not sure. Still is early here

  3. #3
    Join Date
    Oct 2000
    Location
    Australia
    Posts
    538
    There being more than one way to do these things, here's another option:

    SELECT DISTINCT eid FROM table WHERE sid IN (78, 38)

    Note that you shouldn't need the GROUP BY bit in any case if you've got the DISTINCT/UNIQUE.

Posting Permissions

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