目前系统中有一张表,要查出来在页面显示,但是表中有很多保存的是ID,需要关联其他表查出具体的值显示在页面中
这样的字段很多,现在用这种方式查询:select h.a, h.b,
(select hh.mc from table2 hh where hh.id = h.id) h.c, --类似这种子查询很多,如果数据少的话还可以,多了就不行了
...
from table1 h
这样的查询方式, 和把 关联的表都放在一起查询(如下),效率上有差别么?select h.a, h.b, h.c, ...
from table1 h ,table2 hh,...
where h.id = hh.id
求高效的查询语句
这样的字段很多,现在用这种方式查询:select h.a, h.b,
(select hh.mc from table2 hh where hh.id = h.id) h.c, --类似这种子查询很多,如果数据少的话还可以,多了就不行了
...
from table1 h
这样的查询方式, 和把 关联的表都放在一起查询(如下),效率上有差别么?select h.a, h.b, h.c, ...
from table1 h ,table2 hh,...
where h.id = hh.id
求高效的查询语句
from table1 h ,table2 hh,...
where h.id = hh.id------这种效率最高了。