表1的结构如下
clum : id code flg
date : 001 00 2
004 00 2
010 00 2
006 00 3
007 00 2
009 00 3
003 00 4
表2的结构如下
clum : id code X_1 X_2
date : 001 00 2 1
002 00 1 3
003 00 2 1
004 00 3 2
005 00 3 0
006 00 7 2
007 00 4 3
008 00 4 8
009 01 2 1
010 01 2 5
011 01 3 2
查询表1 flg列所为为2的ID,并以此结果为条件,查询表2中ID与之相同的行要求得结果:
clum : id code X_1 X_2
date : 001 00 2 1
004 00 3 2
007 00 4 3
010 01 2 5 小弟这厢先行谢过%
clum : id code flg
date : 001 00 2
004 00 2
010 00 2
006 00 3
007 00 2
009 00 3
003 00 4
表2的结构如下
clum : id code X_1 X_2
date : 001 00 2 1
002 00 1 3
003 00 2 1
004 00 3 2
005 00 3 0
006 00 7 2
007 00 4 3
008 00 4 8
009 01 2 1
010 01 2 5
011 01 3 2
查询表1 flg列所为为2的ID,并以此结果为条件,查询表2中ID与之相同的行要求得结果:
clum : id code X_1 X_2
date : 001 00 2 1
004 00 3 2
007 00 4 3
010 01 2 5 小弟这厢先行谢过%
select t2.id, t2.code, t2.x_1, t2.x_2
from (select * from table1 where flg = 2) t1, table t2
where t1.id = t2.id
或者
select t2.id, t2.code, t2.x_1, t2.x_2
from table1, table2 t2
where t1.id = t2.id
and t1.flg = 2