WHERE, AND OR NOT, ORDER BY
WHERE is used to filter records based on some conditions
SYNTAX
SELECT column1, column2 column3 FROM table_name
WHERE condition;
EXAMPLE
SELECT * FROM Customers WHERE Country='INDIA';
AND , OR operators are used to filter records based on more than one conditions. (All conditions must be tree)
AND is used to apply multiple condition, while OR is used to apply single condition from multiple condition. (at least single condition must be true)
SYNTAX FOR AND
SELECT column1, column2, column3,
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
EXAMPLE
SELECT * FROM Customers WHERE Country='INDIA' AND state = 'GUJARAT';
SYNTAX FOR OR
SELECT column1, column2, column3,
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
EXAMPLE
SELECT * FROM Customers WHERE Country='INDIA' OR state = 'CANADA';
ORDER BY is used to retrieve records in ascending or descending order
SYNTAX
SELECT column1, column2, column3,
FROM table_name
ORDER BY column_name ASC | DSC;
EXAMPLE ORDER BY
SELECT * FROM Customers
ORDER BY Country ASC | DSC;
NOT is used to avoid the mentioned conditions and retrieve the remaining records.
EXAMPLE NOT
SELECT * FROM users
WHERE NOT Country='Australia' AND NOT Country='China';