Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
prom-q
Starting Member
2 Posts |
Posted - 2009-05-18 : 07:59:13
|
| i have a table products_country which has two columns one is productid n another one is origin.the query is likeselect productid from products_country where origin like 'us'origin colum say has three entries 'us' 'at' jk'now i have to make a single query that gives product id for all the three entries of origin...thnx in advance |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-18 : 08:12:23
|
[code]select productid from products_country where origin in ( 'us', 'at', 'jk' )group by productidhaving count(*) = 3[/code] ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
prom-q
Starting Member
2 Posts |
Posted - 2009-05-18 : 08:42:16
|
| what does count(*) do??? does it run the thing 3 times each time with new entry.. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-19 : 10:41:33
|
quote: Originally posted by prom-q what does count(*) do??? does it run the thing 3 times each time with new entry..
nope what it does is checks if there exists productid which has three records with values 'us' 'at' jk' and returns those which has all the three |
 |
|
|
|
|
|