开发者

Ignore a WHERE clause if nested query returns nothing?

How do I ignore the second WHERE clause if my inner join doesn't return anything?

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 
L开发者_运维知识库IMIT 1

Basically if my inner join doesn't return anything the query should be:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜