1.组合表查询
select a.* from test1 a test2 b where a.colume = b.colume and ...2.复合查询
select a.* from test1 a where a.colume = (select b.colume from test2 b where ...)假定两条语句都能正确执行!!!!
select a.* from test1 a test2 b where a.colume = b.colume and ...2.复合查询
select a.* from test1 a where a.colume = (select b.colume from test2 b where ...)假定两条语句都能正确执行!!!!
N*(M+1)/2。第二个是N*M 这样一看就知道效率的优劣了
如果select a.* from test1 a where a.colume = (select b.colume from test2 b where ...)能正确执行,说明(select b.colume from test2 b where ...)子查询返回的结果是唯一的!
select a.* from test1 a where a.colume in (select b.colume from test2 b where ...)
这样的话第一条肯定效率高
如果select a.* from test1 a where a.colume = (select b.colume from test2 b where ...)能正确执行,说明(select b.colume from test2 b where ...)子查询返回的结果是唯一的!
-------------------
支持
理由:
如果select a.* from test1 a where a.colume = (select b.colume from test2 b where ...)能正确执行,说明(select b.colume from test2 b where ...)子查询返回的结果是唯一的!