Mysql多表查询,子查询


select * from t11,t16 where t11.id=t16.id;

select * from t11 t,t16 tt where t.id=tt.id;
#笛卡尔集  会出问题
select * from t11 t,t16;
#内链接
select * from t11 INNER JOIN t16 on  t11.id=t16.id;
#左链接
select * from t11 LEFT OUTER JOIN t16 on t11.id = t16.id;
#右链接
select * from t11 RIGHT OUTER JOIN t16 on t11.id = t16.id;

#子查询
select * from t11 where t11.age > ANY (select age from t16);

#机器出现故障的时候才查询log日志  先执行后面的代码  在执行前面的代码  not exists 也是如此
select * from lg where category ='Nginx' and exists (select * from state where Nginx='fail');

#in 子查询
select * from t11 where t11.id in (select id from t16);
#union 子查  唯一性操作 取唯一去重
select * from t11 union select * from t16;
#简单的两张表拼接在一起
select * from t11 union all select * from t16;
发布了25 篇原创文章 · 获赞 0 · 访问量 498

猜你喜欢

转载自blog.csdn.net/luojiawen208/article/details/105033850