All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW. And all the statements end with a semicolon (;). SQL is case insensitive, which means INSERT and insert have same meaning in SQL statements. But MySQL makes difference in table names. So if you are working with MySQL, then you need to give table names as they exist in the database. Commonly used SQl statment are:
SQL CREATE TABLE Statement
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
…..
columnN datatype,
PRIMARY KEY( one or more columns )
);
SQL INSERT INTO Statement
INSERT INTO table_name( column1, column2….columnN)
VALUES ( value1, value2….valueN);
);
SQL SELECT Statement
SELECT * from table_name
or
SELECT column1, column2….columnN FROM table_name;
SQL DISTINCT Clause
SELECT DISTINCT column1, column2….columnN FROM table_name;
SQL WHERE Clause
SELECT column1, column2….columnN FROM table_name WHERE CONDITION;
or
SELECT * from table_name WHERE CONDITION;
SQL AND/OR Clause
SELECT column1, column2….columnN FROM table_name WHERE CONDITION-1 {AND|OR} CONDITION-2;
or
SELECT * FROM table_name WHERE CONDITION-1 {AND|OR} CONDITION-2;
SQL BETWEEN Clause
SELECT column1, column2….columnN FROM table_name WHERE column_name BETWEEN val-1 AND val-2;
or
SELECT * FROM table_name WHERE column_name BETWEEN val-1 AND val-2;
SQL IN Clause
SELECT column1, column2….columnN FROM table_name WHERE column_name IN (val-1, val-2,…val-N);
or
SELECT * FROM table_name WHERE column_name IN (val-1, val-2,…val-N);
SQL LIKE Clause
SELECT column1, column2….columnN FROM table_name WHERE column_name LIKE { PATTERN };
SELECT * FROM table_name WHERE column_name LIKE { PATTERN };
SQL UPDATE Statement
UPDATE table_name SET column1 = value1, column2 = value2….columnN=valueN [ WHERE CONDITION ];
SQL DROP TABLE Statement
DROP TABLE table_name;
SQL DELETE Statement
DELETE FROM table_name WHERE {CONDITION};);
SQL COMMIT Statement
COMMIT;
SQL ROLLBACK Statement
ROLLBACK;