The following tutorial can be used as dictionary for beginner on SQL syntax. SQL syntaxes are used to manipulate data which are select, insert, update, and delete on database.
1. Select
Select command is used to get rows of data from table.
Syntax:
SELECT [column] FROM [table] WHERE [condition] ORDER BY [column]
Example:
SELECT * FROM country_data WHERE city = 'New York' ORDER BY postal_code
SELECT name, age FROM country_data ORDER BY name
2. Insert
Insert command is used to insert row to table.
Syntax:
INSERT INTO [table] (column1, column2, ...) VALUES (data1, data2, ...)
Example:
INSERT INTO country_data (name, age) VALUES ('john','25')
3. Update
Update command is used to modify row on table.
Syntax:
UPDATE [table] SET column1 = data1, column2 = data2, ... WHERE [condition]
Example:
UPDATE country_data SET name = 'john doe', age='30' WHERE id = 1
4. Delete
Delete command is used to remove data from table.
Syntax:
DELETE FROM [table] WHERE [condition]
Example:
DELETE FROM country_data WHERE name = 'john'