SELECT <column1>, <Column2>, <Column3> FROM <table> WHERE <column1> = 'value' AND <column2> < 6;
Select the product ID, price and name from Products where vend_id is 'DLL01' AND the product price is less than 4
-- Oracle / MySQL / SQL Server SELECT prod_id, prod_price, prod_name FROM Products WHERE vend_id = 'DLL01' AND prod_price < 4;
| prod_id | prod_price | prod_name |
| BNBG01 | 3.49 | Fish bean bag toy |
| BNBG02 | 3.49 | Bird bean bag toy |
| BNBG03 | 3.49 | Rabbit bean bag toy |
SELECT <column1>, <Column2>, <Column3> FROM <table> WHERE <column1> = 'value' OR <column2> < 6;
Select the product name and price from Products where vend_id is 'DLL01' OR 'BRS01'
-- Oracle / MySQL / SQL Server SELECT prod_name, prod_price FROM Products WHERE vend_id = 'DLL01' OR vend_id = 'BRS01';
| prod_name | prod_price |
| Fish bean bag toy | 3.49 |
| Bird bean bag toy | 3.49 |
| Rabbit bean bag toy | 3.49 |
| 8 inch teddy bear | 5.99 |
| 12 inch teddy bear | 8.99 |
| 18 inch teddy bear | 11.99 |
| Raggedy Ann | 4.99 |
SELECT <column1>, <Column2>, <Column3> FROM <table> WHERE <column1> = 'value' AND ( <column2> < 6 OR <column3> > 8 );
Select the product name and price from Products where vend_id is 'DLL01' or 'BRS01' AND prod_price is greater than or equal to 10
-- Oracle / MySQL / SQL Server SELECT prod_name, prod_price FROM Products WHERE (vend_id = 'DLL01' OR vend_id = 'BRS01') AND prod_price >= 10;
| prod_name | prod_price |
| 18 inch teddy bear | 11.99 |
SELECT <column1>, <Column2>, <Column3> FROM <table> WHERE <column1> IN ('value1', 'value2', 'value3');
Advantages of the IN operator:
Select the product name and price from Products where vend_id is 'DLL01' or 'BRS01', and sort the result
-- Oracle / MySQL / SQL Server SELECT prod_name, prod_price FROM Products WHERE vend_id IN ('DLL01', 'BRS01') ORDER BY prod_name;
| prod_name | prod_price |
| 12 inch teddy bear | 8.99 |
| 18 inch teddy bear | 11.99 |
| 8 inch teddy bear | 5.99 |
| Bird bean bag toy | 3.49 |
| Fish bean bag toy | 3.49 |
| Rabbit bean bag toy | 3.49 |
| Raggedy Ann | 4.99 |
SELECT <column1> FROM <table> WHERE NOT <column1> = 'value' ORDER BY <column1>;
SELECT <column1> FROM <table> WHERE <column1> != 'value' ORDER BY <column1>;
SELECT column1 FROM <table> WHERE <column1> NOT IN ('value1', 'value2', 'value3') ORDER BY <column1>;
Select all columns from Products where the product ID is not 'BR01', 'BR02' or 'RGAN01', and sort by product price in descending order
-- Oracle / MySQL / SQL Server SELECT * FROM Products WHERE prod_id NOT IN ('BR01','BR02', 'RGAN01') ORDER BY prod_price DESC;
| prod_id | vend_id | prod_name | prod_price | prod_desc |
| BR03 | BRS01 | 18 inch teddy bear | 11.99 | 18 inch teddy bear comes with cap and jacket |
| RYL01 | FNG01 | King doll | 9.49 | 12 inch king doll with royal garments and crown |
| RYL02 | FNG01 | Queen doll | 9.49 | 12 inch queen doll with royal garments and crown |
| BNBG01 | DLL01 | Fish bean bag toy | 3.49 | Fish bean bag toy complete with bean bag worms with which to feed it |
| BNBG02 | DLL01 | Bird bean bag toy | 3.49 | Bird bean bag toy eggs are not included |
| BNBG03 | DLL01 | Rabbit bean bag toy | 3.49 | Rabbit bean bag toy comes with bean bag carrots |