Page 1 of 1

about searching

Posted: Thu Aug 19, 2004 4:43 am
by bugthefixer
i have a table which has two colums

Code: Select all

track_id         st_id
1                     34
1                     36
1                     22
1                     2
2                     67
2                     54
3                     55
3                     76
3                     43
3                     98
now i want to select track_id where the search key is two st_ids.

like i want to find track id where st_id=34 and st_id=36

it should give me answer 1.

Posted: Thu Aug 19, 2004 4:59 am
by markl999
So something like:
SELECT * FROM foobar WHERE st_id =34 OR st_id =36 GROUP BY track_id

Posted: Mon Aug 23, 2004 1:20 am
by bugthefixer
well it just gives me distnct data but doesnt give data which contains both the st_id not one of them.

Posted: Mon Aug 23, 2004 1:34 am
by feyd
this may be more what you are looking for (untested)

Code: Select all

SELECT a.* FROM foo a, foo b WHERE b.st_id = 36 AND a.st_id = 34