Data Operations
Select -- retrieve data rows and columns from database tables
Insert -- add new data rows to the database table
Delete -- delete data rows from a database table
Update -- update data in the database table
Select
General format:
Select * (field name 1...) from table_name (table name ...)
Where (where clause)
Order by field name DESC (order by clause)
Group by field name (group by clause)
(Field name 1 ...)
You can query multiple fields and use functions such as sum (), max (), min (), and count! The AS alias can be used.
(Table name ...)
Multiple tables can be queried in combination.
(Where clause)
Like, And, Or, between... and.
Like '% find this %'
Like '[A-Za-Z] %' --------- ([] specifies the range of values)
Like '[^ F-M] %' --------- (^ exclude specified range)
Between 20 and 100 -------------- indicates that the condition is in a range.
In (, 30) --------------------------- qualifier
(Order by clause)
Order by stockid DESC (ASC) --------- sort, desc-descending, ASC-ascending
Order by 1, 2 --------- by column number
(Group by clause)
Group by groups tables by row. The specified columns have the same values.
Having count (*) = 2 --------- having: select the specified group.
Keywords
Distinct ----------------- distinct
Select distinct column_name form table_name
Subquery ()
(To be sorted out)
Query Efficiency
Stored Procedure> static view> dynamic connection> subquery