MySQL query

Basic query:

  select * from table name;

Basic condition query:

  select * from Table name where conditions;

  

Fuzzy query:

    select * from table name where name …like ‘%device%’;            Query all the devices that contain ”Information;

    select * from table name where name like’device%’;       query all the information that starts with device in the name;

     select * from table name where name   %Device ‘;      query all information ending with device in name;

    select * from table name where name like like ‘%装%置% ‘;    Query all the information that contains the sequence name of “installation” (before) and “location” (behind) in the name; for example: “Switchdevice “, but cannot find out “置装 switch”;

    select * from table name where name, like, _置_,       Query All names in the name are three words and the middle is “location” information; “_” represents a single arbitrary character;

     can’t find out a comment for now, and then find out the reason and then talk about it # select * from table where name like ‘[lights installed]’; query for all name with” “information; for example:” loaded “or a” lamp unit “” light switch “; < /span>

  

Sorting query:

    select * from table name where name =’device’ order by id asc;      Query all the information whose name is equal to the device and arrange them in order according to id;

select * from table name where order by id=     device; The name is equal to the information of the device and is arranged in reverse order according to the id;

For group query and aggregation functions, see:   

   Aggregate function query: https://www. cnblogs.com/ncwoniu/p/11589200.html

Paging query:

    select * from t_student where st_name like’%张%’ order by st_id limit 0 ,10;     query the information that contains “Zhang” in the name, and the 10 data starting from the first will be displayed after the id is sorted; the paging query must be sorted first

Inner connection:

  select * from Table 1 Join Table 2 on Table1.id = Table2.id;  Query the intersection of the data in Table 1 and Table 2 that meet the conditions after on;

< /p>

External connection:

  Left connection:

     select * from table 1 left join table 2 on table 1.id = table 2.id; after the query matches on The intersection of the data in Table 1 and Table 2 of the conditions Add the remaining data in Table 1 on the left;

  right connection:

     select * from Table 1 right join Table 2 on Table 1.id = Table 2.id ;  Query the intersection of the data in Table 1 and Table 2 that meet the conditions of on Add the remaining data in Table 2 on the right;

Multi-table connection:

  select Table1.id, Table1.name, Table2.name from Table1, Table2 where Table1.id = Table2 .id;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2975 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.