T-SQL Tutorial

SQL And - Or


Store table:

OBJECT_IDPRICENAME
1200A
2500B
3900C
4500D

Example 1:

SELECT * FROM store
WHERE name='B' AND price = 500;

OBJECT_IDPRICENAME
2500B

Example 2:

SELECT * FROM store
WHERE name='B' OR price = 500;

OBJECT_IDPRICENAME
2500B
4500D

Example 3:

SELECT * FROM store
WHERE price = 900 AND (name='A' OR name='C');

OBJECT_IDPRICENAME
3900C