Results 1 to 3 of 3
Thread: MySQL query question.
-
10-23-2003, 03:02 AM #1WHT Addict
- Join Date
- Dec 2002
- Posts
- 106
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
-
10-23-2003, 03:22 AM #2Web Hosting Master
- 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
-
10-23-2003, 08:28 AM #3Closed
- 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.