MySQL Statements (Basic)
MySQL Statements (Basic)
5. SELECT DISTINCT (SELECT DISTINCT statement is used to return only distinct values)
SELECT DISTINCT column1, column2, ...
FROM table_name;
Page: 1
8. DELETE (DELETE statement is used to delete existing records in a table)
DELETE FROM table_name WHERE condition;
/*OR Syntax*/
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
/*NOT Syntax*/
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
/*IN Syntax*/
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...);
/*LIKE Syntax*/
/*Wildcards (%) (_)*/
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
/*BETWEEN Syntax*/
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
Page: 2
11. ORDER BY (Used to sort the result-set in ascending or descending order)
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
13. LIMIT, OFFSET (LIMIT clause is used to specify the number of records to return)
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number OFFSET starting position;
14. Constraints (constraints are used to specify rules for data in a table)
CREATE TABLE table_name (
col_name1 datatype constraint
.........
);
Page: 3