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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 need help with sub-queries

Author  Topic 

sriviswa
Starting Member

1 Post

Posted - 2005-06-29 : 07:00:54
Hi,

I have a table product_cities that has product_id+city_id as its key.

I need to find all products that are listed within a selected list of cities. The product should be listed in each and every city selected.

Suppose I select Boston, Chicago and Denver, the select should list all products that is listed in each of these cities.

Hope I made myself clear.

And thx for all the help.

Vis.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-29 : 07:23:51
Something like

Select columns from products where City in (Citylists)

Can you post the table structures?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

eralper
Yak Posting Veteran

66 Posts

Posted - 2005-06-29 : 16:17:16
Hi,

Is you need a table with columns cityname, productname?



select
city_name,
product_name
from product_cities, cities, products
where
product_cities.city_id = cities.city_id and
product_cities.product_id = products.product_id and
cities.city_name in ('Boston', 'Chicago', 'Denver')
order by cities.city_name



Eralper



-------------
Eralper
http://www.kodyaz.com
Go to Top of Page
   

- Advertisement -