use xie
go
select *from Table_1
select *from table_6
select *from table_4

select *from Table_1 where ok=567  --父查询
select *from Table_1 where ok=(select  ok from  table_6 where jj=78) --子查询 
 
select name from table_4 where id=(
select name from Table_1 where ok=(select  ok from  table_6 where jj=78) ) --3表子查询
/*
1、子查询必须是放在括号里面的、先执行子查询、然后再根据查询的结果为父查询的条件来查
   比如上面子查询的结果是‘567’,那父查询的条件ok=567的时候查的是什么结果、就是这样
2、子查询在‘=,<,>’前面,像这些比较运算符只允许一个列名、就是不能用select * from查全部或selct 列2,列2,列3 from多个查询
3、order by不能放在子查询后面、只能在括号之外的父查询后面
*/
select ok as 没有,go_id as 滚 
from Table_1 as a
inner join table_4 as b on a.ID=78
where a.ID=78                          --子查询的结果也可以用多表内、外连接来查、而且内外连接可以查任何字段、而子查询只能查主表内的字段

更多详细教程、请关注我的微信公众号:客兴天下

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐