Return all or nothing SQL Statement help...
***This is cross-posted in SQL Server 2005. I couldn't find a way to move the original mis-posted question here. I know this is a faux-pas.***
I have a table that has multiple rows with the same value in column 'x' with 'x' being the name of an item in this case. So 'x' might have 4 or 5 rows with 'y' and 'z' containing different data. Column 'z' is a true/false column and 'y' has different traits about 'x'. I want to have it so that when I select 'x' it only appears in the output when every 'x' row has a 'z' value of 'True'.
I know that the above is verbose. I'll paste what I have below with comments...
SELECT dbo.Drink.Title, dbo.Ingredient.Title AS Ingredient, dbo.Component.NumUnitsMin, dbo.Unit.UnitName, dbo.Ingredient.IsInMyBar
FROM dbo.Drink INNER JOIN
dbo.Component ON dbo.Drink.DrinkID = dbo.Component.DrinkID INNER JOIN
dbo.Ingredient ON dbo.Component.IngredID = dbo.Ingredient.IngredID INNER JOIN
dbo.Unit ON dbo.Component.UnitID = dbo.Unit.UnitID
WHERE IsInMyBar = 'True' //Trying to limit but oviously this is wrong. For every 'x' there should be no 'x' returned while 'z' = 'true'
Thanks, I've played for hours trying to write a proper where clause.
brux2dc
|