选择我正在努力工作
SELECT DISTINCT a.client_key, client_name
FROM Bloggers AS a
LEFT JOIN BloggersPosts AS b
ON a.client_key = b.client_key
WHERE a.status = 1 AND
0 NOT IN (SELECT MIN(STATUS) FROM BloggersPosts AS c WHERE c.client_key=a.client_key)
由于某种原因,0 NOT IN (SELECT MIN(STATUS) FROM BloggersPosts AS c WHERE c.client_key=a.client_key)
无法正常工作,有什么想法可以让它发挥作用吗?
SELECT MIN(STATUS) FROM BloggersPosts
时 - 它返回1,这意味着将其作为子选择 - 也应该返回结果,但它不会返回结果。
谢谢
答案 0 :(得分:0)
我希望这能完成你的工作。为您的问题尝试不同的解决方案。
SELECT DISTINCT a.client_key, client_name
FROM Bloggers AS a
JOIN (SELECT client_key, MIN(STATUS) minstatus FROM BloggersPosts GROUP BY client_key) b
ON a.client_key = b.client_key AND minstatus <> 0
WHERE a.status = 1
答案 1 :(得分:0)
使用JOIN,类似的东西:
SELECT DISTINCT a.client_key, client_name, MIN(c.STATUS) blog_status
FROM Bloggers AS a
LEFT JOIN BloggersPosts AS b ON a.client_key = b.client_key
LEFT JOIN BloggersPosts AS c ON c.client_key = a.client_key
WHERE a.status = 1
HAVING blog_status <> 0