Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql for producing same product_name with unique product_id. 1

Status
Not open for further replies.

qyllr

MIS
Mar 8, 2001
131
US
querying against a product table. what's the best way to produce an output with all the records that have the same product_name but have different product_id_number's? product_id_number is the primary key for the product table. i am trying to just collect all the product_id_number's from the query.
 
Hiya,

The query that you want is

SELECT a.product_id_number,
a.product_name
FROM table a
WHERE a.product_id_number IN (SELECT b.product_id_number
FROM table b
WHERE b.product_name = 'whatever')

Tim
 
hi,

this is not working...do you have any other suggestions?

thanks...
 
Thanks for the jump start...I decided to use a self join and != in my where clause and that worked.

q.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top