码迷,mamicode.com
首页 > 数据库 > 详细

Mysql 函数

时间:2018-04-16 20:40:21      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:where   like   col   字符串拼接   any   null   sha   mys   字符串   

%:匹配零个及多个任意字符; _:与任意单字符匹配; []:匹配一个范围; [^]:排除一个范围
Symbol Meaning 
like ‘5[%]‘ 5% 
like ‘[_]n‘ _n 
like ‘[a-cdf]‘ a, b, c, d, or f 
like ‘[-acdf]‘ -, a, c, d, or f 
like ‘[[]‘ [ 
like ‘]‘ ] 
like ‘abc[_]d%‘ abc_d and abc_de 
like ‘abc[def]‘ abcd, abce, and abcf 
like ‘[^1-9]‘
like ‘[^1-9b-z]‘ 0, a
对于字符串中出现的特殊字符:‘%‘,‘[‘,‘[]‘, ‘_‘ 可以使用 ‘[]‘ 把它们包含起来,这样在匹配模式(pattern)中,它们就被当作普通字符对待了。
查询
select * from (文件名) where (条件 xxx=‘xxx‘);
and :
=
!=
<,>,<>
like


select count(1) from anyun_tbl; (查询总条数)
+----------+
| count(1) |
+----------+
|        3 |
+----------+
select count(1) as ‘number‘ from anyun_tbl where anyun_name = ‘上海‘;
+--------+
| number |
+--------+
|      1 |
+--------+

select count(1) as ‘number‘,anyun_name from anyun_tbl where anyun_name = ‘北京‘;
+--------+------------+
| number | anyun_name |
+--------+------------+
|      1 | NULL       |
+--------+------------+


字符串拼接
select concat(‘1‘,‘2‘);
+-----------------+
| concat(‘1‘,‘2‘) |
+-----------------+
| 12              |
+-----------------+

select concat(anyun_id,‘-‘,anyun_name) from anyun_tbl;
+---------------------------------+
| concat(anyun_id,‘-‘,anyun_name) |
+---------------------------------+
| 1-shanghai                      |
| 2-beijing                       |
| 3-hubie                         |
+---------------------------------+


Mysql 函数

标签:where   like   col   字符串拼接   any   null   sha   mys   字符串   

原文地址:https://www.cnblogs.com/superashui/p/8858165.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!