Mysql学习笔记

  1. group by(注意使用位置在where条件后面)
select * from user where name group by name;
  1. with rollup(可以实现在分组统计的基础上,再进行相同的统计(sum,avg,count...))
select coalesce(name,'总数'),sum(singin) as singin_count from employee group by name with rollup;
  1. union(用于连接两个以上select语句的结果到一个结果集合中,默认会删除重复的数据)
select country from websites 
union
select country from apps
order by country;
  1. insert into ... select (复制表)
  2. select ... into outfile (导出数据)
  • 在下面的例子中,生成一个文件,各值用逗号隔开。这种格式可以被许多程序使用:
select a,b,a+b into outfile '/tmp/result.text'
fields terminated by ',' optionally enclosed by '"'
from test_table
  1. 导入
  • mysql命令导入
  • source命令导入
  • 使用load data导入数据
  • 使用mysqlimport导入数据
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容