这一个查询条件可不可以进行优化使到只查询执行一次就可得出所有的数据?现table1有字段 id,name,description,另table2有:firstID,secondID,description,(其中两个ID都是table1的id外关键字),现在要求从table2中查找出firstID = 10,并要求显示description内容是为secondID (假设为12) 的description,因为secondID也是从table1的数据来的,所以又要查一次table1(id=12 and description = 'xxx')。
---------------------------------------------------------------
select * from table2,table2 table3 where table2.firstid=10 and table3.secondid=12 and table2.description=table3.description
---------------------------------------------------------------
select a.fid,a.sid,b.Description from table2 a,table1 b where a.fid='1' and a.sid=b.id
---------------------------------------------------------------
是要这样的结果?
FID SID Description
1, 2 des2
1, 3 des3