首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL 基本语句记录

MySQL 基本语句记录

作者头像
白墨石
发布2021-01-13 14:20:29
1.4K0
发布2021-01-13 14:20:29
举报
文章被收录于专栏:生信情报站生信情报站

-- 查询 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 )

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-05-06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档