SQL - Series - Basic Commands - ORDER BY, INSERT INTO, NULL VALUES, UPDATE, DELETE

ORDER BY

The ORDER BY is used to sort the RESULT-SET in ascending or descending order

The ORDER BY Keywords sorts the records in ascending order by DEFAULT or else we can use ASC. To sort the records in descending order, use the DESC Keyword.

Syntax

SELECT COLUMN1, COLUMN2, ...

FROM TABLE_NAME

ORDER BY COLUMN1, COLUMN2, ... ASC|DESC;


INSERT INTO 

The INSERT INTO is used to insert new records in a table

Syntax

INSERT INTO TABLE_NAME (COLUMN1, COLUMN2, COLUMN3, ..)

VALUES (VALUE1, VALUE2, VALUE3, ..)


NULL VALUES

A field with a NULL value is a field with no value.

If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value.

IS NULL Syntax

SELECT COLUMN_NAMES

FROM TABLE_NAME

WHERE COLUMN_NAME IS NULL;


IS NOT NULL Syntax

SELECT COLUMN_NAMES

FROM TABLE_NAME

WHERE COLUMN_NAME IS NOT NULL;


UPDATE 

The UPDATE Statement is used to modify the records in a table.

Syntax

UPDATE TABLE_NAME

SET COLUMN1=VALUE1, COLUMN2=VALUE2

WHERE CONDITION;


DELETE 

The DELETE Statement is used to delete existing records in a table

Syntax

DELETE FROM TABLE_NAME WHERE CONDITION;



Comments