systemctl start mysqld
limit n, m; n+1开始返回m行
having 对group by之后的数据进行过滤,对统计结果筛选
select (math+chinese+english) as total from score
select avg(math) as m from score group by class having m > 80;
select english, (case when a in (1,3,5) then
when english > 90 then 'A'
when english > 69 then 'b'
else 'C' end) from score;
select column from table1 [inner/left/right/full] join table2 on t1.c1 = t2.c2
Mysql不支持full join,通过left union right方式
union去重,union all保留重复值
CREATE VIEW table3 AS
select u1.user_name as user_name, u2.user_name as f_name from friend f
left join user u1 on f.user_id = u1.user_id
left join user u2 on f.friend_id =u2.user_id