%:匹配零个及多个任意字符; _:与任意单字符匹配; []:匹配一个范围; [^]:排除一个范围
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                         |
+---------------------------------+


posted on 2018-04-16 19:54  super阿水  阅读(94)  评论(0)    收藏  举报