作者:晟文刀
链接:https://www.jianshu.com/p/db050b8914b2
來源:简书
select name from 表名 where name like '%zhang%';
select substr(列名,1,3)from 表名; 查询字节
select min()取最小值
select sum()求和
group_count () 拼接
select ascii 查询ascii码
select concat (‘a’,‘b’) 拼接 字符串
select left (‘123’,2)返回左边的字符
select name, if(passwd='111111','weekpasswd',*****')as from 表名
select name,case when passewd='111111' then 'weekpasswd' else '******' end as from 表名
联合查询 xxxx union xxxx
查询列的个数必须一致, select1 union select2; left join
union select
3,临时表
left join inner join 用法 order by 排序
join
inner join
left join
right join
order by
创建表
mysql> CREATE TABLE world(
-> id INT NOT NULL AUTO_INCREMENT,
-> name VARCHAR(100) NOT NULL,
-> parent_id INT NOT NULL,
-> level INT NOT NULL,
-> PRIMARY KEY (id)
-> )ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.43 sec)