Database Grooming (check line)

Seek operation select distinct field lines from the library name. Seek operation table where group by. 1 row 1.1 single-table queries select distinct fields. Table where conditional statement group by a packet having the filter from the library name sort order by limit limits the number of first performed where, then group by group, HAVING filter according to field selection select the required display, DISTINCT deduplication, order by sort, the number of Distinct limit limits shown: in front of the field if the field is a plurality, it must the contents are repeated multiple fields will go heavy. Select: four operations can be performed, such as the salary is the primary field, may be required to display showing annual salary * 12; Concat () where splicing is required field for the custom field display format Where: 1. 2 Comparison operators .between XX and YY closed interval [xx, yy] 3.in (xx, yy) may be xx or yy 4.like 'al%':. al arbitrary length of bits beginning with 5 available regular Group by: select avg (field) from within the group by the condition field (category field) is not obtained in all the sub-group members, but the first data Having each group: aggregation function may be used to filter, not WHERE Order by: default ascending. Two or multiple conditions, then the first condition Oita, according to the second condition in the group of small points Limit: 0,5 5 represents taking a total of data from the beginning 3,5 = 4,5,6,7 , table 8 over 1.2 query Select * from table 1, table 2 is the Cartesian product obtained at this time and the operation table, all the tables corresponding to all of the data over two select employee.name from employee, department where employee.dep_id = department .id and department.name = 'technology'; Obtained using a conditional statement table, corresponding to the merge operation, with the corresponding relationship between the Cartesian product of the filter is completed, the disadvantage is unclear semantic Select field from table 1 left / right / inner join left table in Table 2 Left primary table, from the right to data table must show all the main table, the content display field is not null Inner retained condition and a subsequent set of queries subtable 1.3: the results of the query statement as a filter condition to another statement select name, age from emp where age> (select avg (age) from emp) where the use of the statement which can only follow a sub-query Exist: if the result is true behind the execution is carried out, or do not execute the previous statement, and the content itself is independent of the front. select * from employee where exists (select id from department where id = 204);

Guess you like

Origin www.cnblogs.com/shachengcc1/p/11444167.html