Click here to Skip to main content
15,914,215 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am displaying product names along with category id's and subcategory id's which are act as foreign key here...but i want to display id names which are present in category and subcategory table...already in one page i am displaying all category names and sub category names and storing their respective id's in product table...but in one page i need to display category and subcategory names which are not present in product table instead their id's are present here...please help me
Posted
Comments
Sandeep Mewara 16-May-12 8:38am    
Not clear.

If I understood the question correctly, you can use NOT EXISTS for this. Something like:

SQL
SELECT * 
FROM Category c
WHERE NOT EXISTS( SELECT 1
                  FROM Product p
                  WHERE p.CategoryId = c.CategoryId);
 
Share this answer
 
Not Exists or Not In, any one can be used.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900