codescracker


sql

SQL Syntax



« Previous Tutorial Next Tutorial »


Before learning SQL, you must have to understand about the basic syntax of SQL. Here are the general syntax of some SQL clauses and statements. Every SQL statements ends with a semicolon (;).

SQL SELECT Statement Syntax

Here is the syntax of the SQL select statement:

SELECT col1, col2, col3, ..., colN
FROM table_name;

To learn more about SQL SELECT statement, refer to SQL Select

SQL INSERT INTO Statement Syntax

Here is the syntax of the SQL INSERT INTO statement:

INSERT INTO table_name(col1, col2, col3, ..., colN)
VALUES(val1, val2, val3, ..., valN);

To learn more about SQL INSERT INTO statement, refer to SQL Insert Into

SQL DISTINCT Clause Syntax

Following is the syntax of the SQL DISTINCT clause:

SELECT DISTINCT col1, col2, col3, ...., colN
FROM table_name;

To learn more about SQL DISTINCT clause, refer to SQL Distinct

SQL WHERE Clause Syntax

Below is the syntax of the SQL WHERE clause:

SELECT col1, col2, col3, ..., colN
FROM table_name
WHERE CONDITION;

Refer to SQL Where to learn more about SQL where clause

SQL IN Clause Syntax

The syntax of the SQL IN clause is show here:

SELECT col1, col2, col3, ..., colN
FROM table_name
WHERE column_name IN (val1, val2, val3, ..., valN);

To learn in detail about SQL IN clause, refer to SQL In

SQL AND/OR Clause Syntax

The syntax of the SQL AND/OR clause is shown below:

SELECT col1, col2, col3, ..., colN
FROM table_name
WHERE  CONDITION-1 {AND|OR} CONDITION-2;

To learn in detail about SQL AND/OR clause then refer to SQL And & Or

SQL BETWEEN Clause Syntax

Below is the syntax of the SQL BETWEEN clause:

SELECT col1, col2, col3, ...., colN
FROM table_name
WHERE column_name BETWEEN val1 AND val2;

To achieve detail knowledge about SQL BETWEEN clause, refer to SQL Between

SQL LIKE Clause Syntax

Here is the syntax of the SQL LIKE clause:

SELECT col1, col2, col3, ..., colN
FROM table_name
WHERE column_name LIKE {PATTERN};

To get some detail knowledge about SQL LIKE clause, then refer to SQL Like

SQL GROUP BY Clause Syntax

Below is the syntax of the SQL GROUP BY clause:

SELECT SUM(column_name)
FROM  table_name
WHERE  CONDITION
GROUP BY column_name;

To learn more about SQL GROUP BY clause, refer to SQL Group By

SQL ORDER BY Clause Syntax

Below is the syntax of the SQL ORDER BY clause:

SELECT col1, col2, col3, ..., colN
FROM table_name
WHERE CONDITION
ORDER BY column_name{ASC|DESC};

To learn more about SQL ORDER BY clause, refer to SQL Order By

SQL DROP TABLE Statement Syntax

Here is the syntax of the SQL DROP TABLE statement:

DROP TABLE table_name;

To learn more about SQL DROP TABLE statement, refer to SQL Drop Table

SQL CREATE TABLE Statement Syntax

Here is the syntax of the SQL CREATE TABLE statement:

CREATE TABLE table_name(
col1 datatype,
col2 datatype,
col3 datatype,
.....
colN datatype,
PRIMARY KEY(one or more columns)
);

To learn in detail about SQL CREATE TABLE statement, refer to SQL Create Table

SQL CREATE INDEX Statement Syntax

The syntax of the SQL CREATE INDEX statement is shown here:

CREATE UNIQUE INDEX index_name
ON table_name(col1, col2, col3, ..., colN);

To learn more about SQL CREATE INDEX statement, refer to SQL Create Index

SQL DELETE Statement Syntax

The syntax of the SQL DELETE statement is shown here:

DELETE FROM table_name
WHERE  {CONDITION};

To learn in detail about SQL DELETE statement, refer to SQL Delete

SQL UPDATE Statement Syntax

The syntax of the SQL UPDATE statement is shown here:

UPDATE table_name
SET col1 = val1, col2 = val2, col3 = val3, ..., colN=valN
[WHERE  CONDITION];

To learn in detail about SQL UPDATE statement then refer to SQL Update

SQL CREATE DATABASE Statement Syntax

The syntax of the SQL CREATE DATABASE statement is shown below:

CREATE DATABASE database_name;

To achieve more knowledge about SQL CREATE DATABASE statement then refer to SQL Create Database

SQL DROP DATABASE Statement Syntax

Following is the syntax of the SQL DROP DATABASE statement:

DROP DATABASE database_name;

To learn in detail about SQL DROP DATABASE statement, refer to SQL Drop Database


« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test