SQL statement sorting, SQL statements
1. select * from login where name like '% admin %' limit; 2. there are two data tables. The user (id, name) Table records the user ID and nickname. The table article (id, title, content, time) records the title, content, and time of the user's post, and writes an SQL statement to print the nickname of each user and the total number of published articles. Select user. name, article. id, article. total from user, (select id, count (*) as 'Total' from article group by id) as a where user. id = article. id; 3. write the SQL statement for the names of the top 10 people who have posted the most posts. The following table is used: member (id, username, posts, pass, email) Select * from 'member' order by posts desc limit; 4. query and print the name = zhangsan from the user table. Select * from user where name = 'zhang san'; 5. Common SQL commands: Show database Show tables Insert into Table name () values ()
Update table name set field = value where... Select * from table name where condition order...
6. Left join write an SQL statement Select A. id, A. class from A left join B on A. cid = B. id;
7. display the databases on the current server: show databases;
8. display the SQL statement for creating a database: show create database mysql;
9. display the SQL statement for creating a table: show create table user;
10. query the structure of the user table: desc user;
11. Obtain select-related information: explain select * from user;
12. display which threads are running: show processlist;
13. Display System variables and values: show variables;
14. The system variable name contains the conn value: Show variables like '% conn % ';