Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL Server Query Code Help

$
0
0

Hi all. I'm having a heck of a time trying to get my query to work. I have a table of ingredients:

___________________________________

ID  NAME                             INGREDIENTS

1   KITCHEN SINK COOKIES  EGGS

2   KITCHEN SINK COOKIES  FLOUR

3   KITCHEN SINK COOKIES  MILK

3   NO BAKE COOKIES II       BAKING SODA

___________________________________

My query:

SELECT NAME

FROM dbo.Ingred

WHERE INGRED <> 'eggs';

Problem is my results return both KITCHEN SINK COOKIES and NO BAKE COOKIES II because rows 2 and 3 do not have eggs. How can I write this query to exclude all instances of KITCHEN SINK COOKIES when eggs is found?

Many Thanks!


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>