Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 29th, 2007, 09:18 PM
Registered User
Join Date: May 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
                      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.

Old May 30th, 2007, 03:44 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

May be I am confused! to correlate the column 'X' with your select statement. You should have used the Column name in question instead of referring it as 'X'

- Vijay G
Strive for Perfection

Similar Threads
Thread Thread Starter Forum Replies Last Post
SELECT statement nullifying RETURN value Bob Bedell ADO.NET 2 January 18th, 2008 09:17 PM
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
Sql Return question jezywrap ASP.NET 1.0 and 1.1 Professional 20 December 21st, 2006 05:58 PM
return to value in <SELECT> statement mikeuk Beginning PHP 3 September 25th, 2004 08:46 AM
Return Statement CodeMonkeys C# 4 August 25th, 2004 11:33 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.