SQL statement sorting, SQL statements

Source: Internet
Author: User

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 % ';

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.