Simple sql statement to the database

1, the query

select the column name from the table name;

select the column name alias from table where + query;

Fuzzy query:

select * from table where column names like "% + content";

Co-table query:

select column names from Table 1 inner join Table 2 on Table 1.id = Table 2.parent_id; - the coupling using comparison matches two rows in a table according to a total value of each table column. For example, students and retrieve identification numbers of all high school students table courses same row.  

select from table column names in Table 1 left join 1.id = Table 2 on Table 2.parent_id; - left join result set includes LEFT OUTER clause left table specified in all rows, not just join column the matching lines. If you do not match the right table rows in a row left the table, select a list of all the rows in the result set associated with the right table columns are null. 

select from table column names in Table 1 right join 1.id = Table 2 on Table 2.parent_id; - right outer join is the reverse link of a left outer coupling. Returns all rows in the right table. If there are no matching rows in a row left the table and right table will return a null value for the left table.    

Sort by:

select the column name from table order by column name desc; - in descending order

select the column order by name from table column names (asc); - Ascending

2, the new

inset into the table names (column names) values ​​(value);

3, update, modify data

update table set column where the column name = value = value;

Guess you like

Origin www.cnblogs.com/yuer02/p/12141770.html