;

SQL Syntax


SQL follows some unique set of rules and guidelines called syntax. The SQL syntax is quite an easy one to learn. Here, in this tutorial, we are providing all the basic SQL syntax.

SQL is not case sensitive which means SELECT and select have the same meaning in SQL statements.

SQL syntax allows us to write the SQL statement line breaks at logical points without it breaking the statement.

All the SQL statements start with any of the keywords like, SELECTINSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;). There are some exceptions where a semicolon may be omitted.

Here are the various syntax for SQL statements. All the SQL Statement Syntax Follow the tutorials:

SELECT Statement

Example - SELECT Statement
SELECT * FROM tableName; //here * represent all the columns
Example - of SELECT Statement
SELECT column1, column2....columnN
FROM tableName;

DISTINCT Clause

Example - SELECT DISTINCT Statement
SELECT DISTINCT column1, column2...columnN
FROM tableName;

WHERE Clause

Example - WHERE Clause
SELECT column1, column2....columnN
FROM tableName
WHERE Condition;

AND/OR Clause

Example - AND Clause 
SELECT column1, column2....columnN
FROM tableName
WHERE Condition1 AND Condition2;
Example - OR Clause
SELECT column1, column2....columnN
FROM tableName
WHERE Condition1 OR Condition2;

IN Clause

Example - IN Clause
SELECT column1, column2....columnN
FROM tableName
WHERE column_name IN (val1, val2,...val-N);

BETWEEN Clause

Example - BETWEEN Clause
SELECT column1, column2....columnN
FROM tableName
WHERE columnName BETWEEN val1 AND val2;

These are some SQL Statement syntax given above and for all other SQL statements syntax follow the tutorials.