有二个表:
table1:
Field1 field2 field3
a1 b1 c1
a2 b2 c2
a3 b3 c3
a4 b4 c4table2
field1 fieldx fieldy
a1 x1 y1
a2 x2 y2
a4 x4 y4想用一句SQL形成一个数据集:
Field1 field2 field3 fieldx fieldy
a1 b1 c1 x1 y1
a2 b2 c2 x2 y2
a3 b3 c3
a4 b4 c4 x4 y4请问这样的SQL怎么写?谢谢!
table1:
Field1 field2 field3
a1 b1 c1
a2 b2 c2
a3 b3 c3
a4 b4 c4table2
field1 fieldx fieldy
a1 x1 y1
a2 x2 y2
a4 x4 y4想用一句SQL形成一个数据集:
Field1 field2 field3 fieldx fieldy
a1 b1 c1 x1 y1
a2 b2 c2 x2 y2
a3 b3 c3
a4 b4 c4 x4 y4请问这样的SQL怎么写?谢谢!
, field2
, field3
, (select filedx from table2 t21 where t1.field1=t21.field1)
, (select filedy from table2 t22 where t1.field1=t22.field1)
from table1 t1
order by t1.field1
where table1.field1=table2.field1
order by table11.field1
from table1 a left join table2 b on a.field1=b.field1
from table1 a, table2 b
where a.field1=b.field1
order by a.field1
from table1 a
Left join table2 b on a.field1 = b.field1
from table1 a left join table2 b on a.field1=b.field1
select a.Field1,a.field2,a.field3,b.fieldx,b.fieldy
from table1 a left join table2 b on a.field1=b.field1
--and …… -- 若有需要
select a.Field1,a.field2,a.field3,b.fieldx,b.fieldy
from table1 a, table2 b
where a.field1(+)=b.field1
WHERE TABLE1.field1 = table2.field1