operation of the data
Take the first five data in the table
Top 5 from table_name
Take the first 50% of the data in the table
Top percent from table_name
Default ordering; desc indicates descending order (reverse order)
Returns the only distinct value for a column in a table:
DISTINCT column_name from table_name
Fuzzy query, query condition starts with K
like ' K% '
Fuzzy query, the query condition is ending with X
like '%x '
-
_ Instead of one character
SELECT * from Persons WHERE FirstName like ' _eorge '
-
Queries data that ranges between two values. Applies to numeric types, text types, and date types. Different databases, for the processing of boundary values, some databases get the inclusion of two boundaries or a boundary value, and some databases get not including the boundary values.
SELECT col1,col2,col3 from TableA INNER joins TableB on tablea.a_id = tableb.b_id
Different join types differ:
-
- JOIN: Returns a row if there is at least one match in the table, no row is returned if no match (INNER join and join are the same)
- Left JOIN: Returns all rows from the table, even if there are no matches in the right table. Returns all rows of the left table that match the right table, returns the relevant value of the right table to query, and the corresponding column value is empty if the right table does not match
- Right JOIN: Returns all rows from the correct table, even if there is no match in the left table. Ditto.
- Full JOIN: Returns a row as long as there is a match in one of the tables. Collection of left join and right join
Combine result sets of two or more SELECT statements
Insert a new row into the table
VALUES (Val1,val2,val3,..., valn)
Insert new row, specify column to insert new value
Or
INSERT INTO table_name SET VALUES
(Val1,val2,val3,..., Valn)
Insert New row
Updating existing data in a table
Delete some data from the table, where the user name begins with Vuser_:
Delete from ttyz_users where user_name like '%vuser_% '
Delete from table_name where column_name like '%xxx% '
Encounter a problem: error-27796:failed to connect to server "10.133.96.35:80": [10061] Connection refused since the number of virtual users has been set to 1000, it has not been able to solve
SQL statements learn to accumulate and manipulate data