-- 查询
select column1,column2 from table
select column1,column2 from table where id = 1
-- 查询:去掉某字段重复项,结果为这个字段
SELECT DISTINCT (column) FROM table
-- 查询:去掉某字段重复项,结果可指定字段
select * from tablegroup by column
-- 内连接查询
select * from table1,table2 where table1.id = table2.id
select * from table1 inner join table2 on table1.id = table2.id
-- 左右连接查询
select * from table1 right join table2 on table1.id = table2.id
select * from table1 left join table2 on table1.id = table2.id
-- 全连接查询
select * from table1 right join table2 on table1.id = table2.id
union
select * from table1 left join table2 on table1.id = table2.id
-- 限制查询
select * from table1 limit 0,5
------------------------------------------------------------------------------------------------------------
-- 插入
insert into table (column1,column2) values (column_value1,column_value2)
------------------------------------------------------------------------------------------------------------
-- 更新
update table set column1 = 'column_value1',column2 = 'column_value2' where id = 1
------------------------------------------------------------------------------------------------------------
-- 删除
delete from table where id = 1
------------------------------------------------------------------------------------------------------------
-- 排序
select * from table1 order by id
select * from table2 order by id desc
------------------------------------------------------------------------------------------------------------
-- 统计
select max(id) from table1
select min(id) from table1
select sum(id) from table1
select avg(id) from table1
select count(id) from table1 where pid = 1
select count(id) from table1 where table1.pid = table2.pid group by table1.pid
------------------------------------------------------------------------------------------------------------
-- 使用select结果语句创建新表
CREATE TABLE new_table (SELECT * FROM old_table);
CREATE TABLE box_total(
select pathway,pathwayName
FROM (
select pathway,pathwayName from box_human
UNION
select pathway,pathwayName from box_monkey
UNION
SELECT pathway,pathwayName from box_mouse
UNION
SELECT pathway,pathwayName from box_ox
UNION
SELECT pathway,pathwayName from box_pig
UNION
SELECT pathway,pathwayName from box_rat
order by pathway
) as TB
)