mysql2.0

 select a.订单id, a.业务类型 a.单价 a.消费数量 b.用户姓名, b.用户联系方式 from 订单表 a left join 用户表b on a.用户id = b.用户id where b.用户性别 = '男' and (a.单价 * a.消费数量) > 10000 and b.用户id is not null
 
 
 

作者:晟文刀
链接: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)

posted @ 2018-04-16 18:26  snake冰淇凌  阅读(86)  评论(0编辑  收藏  举报