Data query Statements
Select column name, column name, column name ... from table name [where condition]
The column name is the name of the field, note that the last column name does not have a comma, the condition after the table name can be added without adding the data that is only found to satisfy the condition.
Querying user names and passwords in the user table
Select User_name,password from user;
This is only the user name and password in the table, and no conditions
Add a Where condition to isolate all fields that meet the criteria
SELECT * from user where id=1;
Filter out duplicate values
Select distinct mobile from user;
Filter the Mobile field in the user table, and repeat it to find only one
Link fields
Select Concat (user_name,mobile) from user;
Connect the user_name and cell phone number into a single field
Specify the name of the field after the connection
Select Concat (user_name,email) as user_name_email from user;
Add a separator to a field--
Select Concat_ws ("--", user_name,email) from user;
Field Rename
Select User_name as name,email as em from user;
Rename the Found field user_name to name to rename the email to EM
Fuzzy query (scenario: Search)
Like applies to queries with small data volumes (less than 100,000)
Using Sphinx (another technology) with a large amount of data
Select user_name from user where user_name like '%ng% ';
Query the value of the field with the User_name field value,% represents whatever is behind you, as long as value is in this NG will be detected.
%ng represents the left fuzzy ng% represents the right fuzzy%ng% represents the whole fuzzy
---------------------------------------------------
MySQL-Data query statements