試試這個:
select a.id,a.name,a.created,a.status from
(select b.id,a.name,b.created,b.status from
(select count(name) as cnt, name from tbl_sample as a GROUP BY name) as a
LEFT JOIN
(select * from tbl_sample) as b
on a.`name` = b.`name` where cnt>1 and STATUS = 0) as a
LEFT JOIN
(select b.id,b.name,b.created,b.status from
(select count(created) as cnt, created from tbl_sample as a GROUP BY created) as a
LEFT JOIN
(select * from tbl_sample) as b
on a.`created` = b.`created` where cnt>1 and STATUS = 0) as b
on a.id = b.id
我不完全確定你的要求是什麼,但你有嘗試過自我加入嗎? –
@digjack - 所以,如果你有條件「狀態爲0」,那麼第二個條件「狀態爲1」將如何? –
我不確定是誰投票結束這個問題,因爲「太寬泛」,即「太多可能的答案或者好的答案會太長」。這是一個反連接。沒有其他「好」的答案。好的,所以有很多可能的*錯誤的答案。但是這並不能使問題「太寬泛」,來吧。 (如果我們要關閉它應該是因爲它是重複的問題) – spencer7593