Get started with simple SQL
First, Introduction
1, a database contains one or more tables, and the table contains records with data (rows)
2, SQL is not case sensitive, the semicolon of the statement to see the specific situation
Two, grammar
1, Data manipulation language: DML
A) SELECT: Get data from the database
b) Update: Updating data in a database table
c) Delete: Delete data from the database
d) INSERT into: Insert data into the data table
2, data definition language: DDL
A) CREATE database: Creating new databases
b) ALTER database: Modify Databases
c) CREATE table: Creating a new data table
d) ALTER table: Modify data table
e) DROP table: Delete data table
f) CREATE INDEX: Create indexes
g) DROP INDEX: Delete index
Third, SELECT
1, SELECT column name from table name
2, SELECT * from table name
Four, DISTINCT
1, select the data that is unique in the column
2, SELECT DISTINCT column name from table name
Five, where
1, conditional selection
2, SELECT column name from table name WHERE column name operator value
a) = (equals) <> (not equal to) > (greater than) < (less than) >= <= between (in a range) like (search for a pattern)
3, use of quotation marks, values for text need to use quotation marks, numeric values, no quotes required
VI, and and OR
1, concatenate multiple conditions in the WHERE statement
Seven, ORDER by
1, sorts the result set according to the specified column (default ascending), Desc is descending, ASC is ascending
2, SELECT column name from table name ORDER by column name (DESC OR ASC)
Eight, INSERT into
1, INSERT into table name values (value 1, value 2, value 3 ...)
2, INSERT into table name (column 1, column 2,...) Values (value 1, value 2,....)
Nine, UPDATE
1, UPDATE table name set column name = new value WHERE Column name = specified value
2, set multiple columns, separated by commas
Ten, DELETE
1, DELETE * FROM table name
2, DELETE from table name WHERE column NAME = specified value,