如果嵌套查询什么都不返回,请忽略WHERE子句?

时间:2011-10-06 22:24:09

标签: mysql

如果我的内连接没有返回任何内容,如何忽略第二个WHERE子句?

SELECT MAX( DATE ) , URL
FROM History
WHERE UID =  '$uid'
AND DATE < ( SELECT MAX( DATE ) FROM History WHERE URL =  '$url' AND UID =  '$uid' ) 
GROUP BY URL
ORDER BY DATE DESC 
LIMIT 1

基本上,如果我的内部联接不返回任何查询应该是:

SELECT MAX( DATE ) , URL
FROM History
WHERE UID =  '$uid'
GROUP BY URL
ORDER BY DATE DESC 
LIMIT 1

0 个答案:

没有答案