Pages

Wednesday, January 19, 2011

OR & AND

OR & AND
--============================================[OR and AND]=================================================================
--AND clause is used when you want to specify more than one condition in your SQL WHERE clause
--and at the same time you want all conditions to be true.

---AND----
SELECT * FROM Person.Contact
WHERE LastName = 'Achong'
AND
ContactID = '1'

---OR-----
--Using OR clause, we can display all the results which satisfies either of the condition

SELECT * FROM Person.Contact
WHERE LastName = 'Achong'
OR
ContactID <= '10'

--- AND + OR ------
--You can combine AND and OR clauses anyway you want and you can use parentheses to define your logical expressions.

SELECT * FROM Person.Contact
WHERE (FirstName = 'Gustavo' OR FirstName = 'Catherine') AND LastName = 'Achong'

No comments:

Post a Comment