Skip navigation links

MySQL Forums :: Newbie :: WHERE AND OR


Advanced Search

WHERE AND OR
Posted by: nathan cobb ()
Date: December 31, 2008 05:37AM

Hello,

I've been struggling to understand how to achieve a certain AND/OR logic.

SELECT id FROM table1 WHERE column1 = 1 AND column2 = 7;

The above query will select the id if column1 and column2 both prove true, and not if column1 does and column2 not.

If I use an OR clause it will stop once column1 proves true and not select using column2 as a condition.

How would I modify this query so that it selects data where column1 is true and where column2 is true without both having to prove true?

I'm sure this is an obvious one. Thanks

Options: ReplyQuote


Subject Written By Posted
WHERE AND OR nathan cobb 12/31/2008 05:37AM
Re: WHERE AND OR nathan cobb 12/31/2008 05:40AM
Re: WHERE AND OR Ron Mey-Ami 12/31/2008 10:07PM
Re: WHERE AND OR Guelphdad Lake 12/31/2008 10:24PM
Re: WHERE AND OR Marc Tonido 01/08/2009 09:21AM
Re: WHERE AND OR nathan stiles 01/09/2009 11:21AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.