日期:2014-05-19  浏览次数:20543 次

在线求SQL语句...
有两张表
A                                 B
-------                 --------
id                           id
content                 viewdate
pubdate
想取出A里面所有pubdate大于B里面viewdate的数据
select   a.*   from   a,b   where   a.id=b.id   and   a.pubdate> b.viewdate
但是B表经常是空的,在该情况下如何取出A表所有记录?
谢谢。

------解决方案--------------------
--错了,改改。
select a.*
from a
left join b on a.id=b.id
where a.pubdate> isnull(b.viewdate,a.pubdate-1)