比如 我有主表 A 的资料是
报价单号 价格 日期
a 1.5 2009.11.1
b 3.5 2009.11.2
c 8 2009.11.5
d 1.2 2009.11.5
e 1.2 2009.11.5
表 B的资料是
报价单号 书名
a b
b b
c b
d c
e a
----------
c b
d c
e a
报价单号 价格 日期
a 1.5 2009.11.1
b 3.5 2009.11.2
c 8 2009.11.5
d 1.2 2009.11.5
e 1.2 2009.11.5
表 B的资料是
报价单号 书名
a b
b b
c b
d c
e a
----------
c b
d c
e a
c b 2009.11.5
d c 2009.11.5
e a 2009.11.5
select B.报价单号,B.书名,A.日期 from B inner join A on B.报价单号=A.报价单号 and A.日期='2009.11.5'这个?
select A.报价单号 , B.书名 , A.日期 from A left join B on A.报价单号=B.报价单号
where A.报价单号 in('c','d','e')
如果你找的是最新的日期的记录的话:
select T.报价单号,B.书名,T.日期
from
(select * from A a1 where not exists(select 1 from A where a1.报价单号=报价单号 and a1.日期<日期)) t inner join B on T.报价单号=B.报价单号