子查詢. 其實不用子查詢.用聯接更簡單,更快 select a.col1,b.col2 from table1 a left join table2 b on b.col1 = a.col1
我看是联接,和下面的语句是一样的; select a.col1,b.col2 from table1 a left join table2 b on a.col1=b.col1
to: sunrisehy2003(黎明) 从效率上说没错,只不过,在实际处理时,有时需要用:select a.col1, (select b.col2 from table2 b where b.col1 = a.col1) col2 from table1 a这种写法而已.
select a.col1,b.col2 from table1 a inner join table2 b on a.col1=b.col1
子查询,不过性能没有left join 优化select a.x ,(select b.y from b where a.x =b.x) y from a先对a 表进行查询遍历(类似游标)在和第一条数据参照b表的条件进行筛选非特殊情况不建议使用
我觉得这种句子是不是可以实现外联接呀? 我认为select a.col1, (select b.col2 from table2 b where b.col1 = a.col1) col2 from table1 a返回table1的所有行 而select a.col1,b.col2 from table1 a left join table2 b on a.col1=b.col1返回a,b的公共行???
http://expert.csdn.net/Expert/topic/2361/2361465.xml?temp=.2815821树形数据的处理
http://expert.csdn.net/Expert/topic/2285/2285830.xml?temp=.7908594查询第X页,每页Y条记录
http://expert.csdn.net/Expert/topic/2365/2365596.xml?temp=.8605615化解字符串不能超过8000的方法
http://expert.csdn.net/Expert/topic/2303/2303308.xml?temp=.8503076
其實不用子查詢.用聯接更簡單,更快
select a.col1,b.col2
from table1 a
left join table2 b
on b.col1 = a.col1
select a.col1,b.col2
from table1 a left join table2 b on a.col1=b.col1
从效率上说没错,只不过,在实际处理时,有时需要用:select a.col1, (select b.col2 from table2 b where b.col1 = a.col1) col2 from table1 a这种写法而已.
from table1 a inner join table2 b on a.col1=b.col1
我认为select a.col1, (select b.col2 from table2 b where b.col1 = a.col1) col2 from table1 a返回table1的所有行
而select a.col1,b.col2
from table1 a left join table2 b on a.col1=b.col1返回a,b的公共行???