MySQL Forums
Forum List  »  Newbie

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
December 31, 2008 05:37AM
December 31, 2008 05:40AM
December 31, 2008 10:07PM
December 31, 2008 10:24PM
January 08, 2009 09:21AM
January 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.