首页 > 其他 > 详细

数据查询语句

时间:2020-01-13 21:30:58      阅读:81      评论:0      收藏:0      [点我收藏+]

一、数据查询语句:DQL

  作用:查询

二、DQL

  #基本查询(可不加where 条件)

  select * from 表名 where 条件;

  select 列1,列2 from 表名 where 条件;

  #过滤掉重复列

  select distinct 列1 from 表名;

  #合并为一行

  select concat (列1,列2) from 表名;

  select concat_ws (‘==‘,列1,列2) from 表名;

  #改名

  slect 列1 as 别名,列名2 as 别名2 from 表名;

  #模糊查询(%匹配所有,_匹配一个)

  select 列名 from 表名 where 列名 like ‘%xx_‘;

  #聚合函数

  #表中记录的条数

  select count(*) from 表名;

  #查询此列的和

  select sum(列名) from 表名;

  #查询此列的平均值

  select avg(列名) from 表名;

  #查询此列的最大值

  select max(列名) from 表名;

  #查询此列的最小值

  select min(列名) from 表名;

  #分组查询

  

数据查询语句

原文:https://www.cnblogs.com/badbadboyyx/p/12189132.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!