The SELECT statement is used to select data from a database.
The data will be returned in json.
FROM <table_name> SELECT <col1, col2, ...>You can also change the order. For example :
SELECT fun, profit FROM real_worldUsing WHERE to filter to result.
FROM <table_name> SELECT <col1, col2, ...>
WHERE <cond1, cond2, ...>The UPDATE statement is used to modify the existing records in a table.
UPDATE <table_name>
SET <col1 = val1, col2 = val2, ...>
WHERE <cond1, cond2, ...>For example :
UPDATE employee
SET salary = 200000
WHERE name = 'ME'The INSERT INTO statement is used to insert new records in a table.
You will need to specify both the column names and the values to be inserted:
INSERT INTO <table_name> (col1, col2, ...)
VALUE (val1, val2, ...)The numbers of column must be same as the numbers of value. For example :
INSERT INTO className (id, name)
VALUE (30, 'Joe')The DELETE statement is used to delete existing records in a table.
There is a difference between HySQL and MySQL, in HySQL, you can specify the columns you want to delete.
DELETE <col1, col2, ...>
FROM <table_name>
WHERE <cond1, cond2, ...>For example :
DELETE id
FROM class
WHERE name = 'Joe'The CREATE statement is used to create a new HySQL table.
CREATE <table_name> (
<col1> <val1>,
<col2> <val2>,
...
)The columns and values will be the col and val of the first data. For example :
CREATE TABLE tree (
Name 'Pinus resinosa',
Kingdom 'Plantae',
Clade 'Tracheophytes'
)The database generated :
[
{
"Name": "Pinus resinosa",
"Kingdom": "Plantae",
"Clade": "Tracheophytes"
}
]The `DROP` statement is used to drop an existing HySQL table.
HySQL can drop multiple tables in one time.
DROP TABLE <table_name1, table_name2, ...>For example :
DROP TABLE tree, class, employee