sql 常用语句
#查询 select * from t_user where id=1; 关联查询 select * from a left join b on a.id=b.id; select * from a right join b on a.id=b.id; select * from a inner join b on a.id=b.id; #union结果集合用 select id,name from a where id=3 union select id,name from b where id=4; #嵌套 select * from (select * from b) where name='linux'l; select * from t_user where id in (select id from t_id); select * from t_user where (id,name) in (select id,name from t_id);
#having二次筛选
select * from t_user where id =4 group by name having count(name)>3;
#between
select * from t_user where id between 1 and 10;
#正则regexp
#匹配name是jin开头
select * from t_user where name regexp '^jin'
#匹配name是jin开头并且是 g和n结尾
select * from t_user where name regexp '^jin.*(g|n)$';