标签:DQL
mysql之DQL查询AS CONCAT LIKE的使用select 列名1,列名2,... from 表名 [where 条件]
过滤掉重复的列值
select distinct 列名1 from 表名
-- 重复的列值只列出一次(去掉列值重复)
mysql> select distinct(password) from user;
连接concat
select concat(列名1,列名2) from 表名 concat_ws带分隔符
列起别名 as
select 列名1 as 别名,列名2 from 表名
模糊查询
select 列名 ... from 表名 where 列名 like ‘%字符串%‘;
mysql> select user_name from user where user_name like ‘%ng%‘;
+-----------+
| user_name |
+-----------+
| liming |
| zhangsan |
+-----------+
Mysql之DQL排序以及聚合函数
order by 字段 asc;
order by 字段 desc;
mysql> select user_name,id from user order by id asc;
+-----------+----+
| user_name | id |
+-----------+----+
| liming | 1 |
| zhangsan | 2 |
| 李华 | 3 |
+-----------+----+
3 rows in set (0.01 sec)
mysql> select user_name,id from user order by id desc;
+-----------+----+
| user_name | id |
+-----------+----+
| 李华 | 3 |
| zhangsan | 2 |
| liming | 1 |
+-----------+----+
3 rows in set (0.00 sec)
标签:DQL
原文地址:http://blog.51cto.com/13480443/2106878