2016-11-30 74 views
0

是他們的任何方式或查詢,以防止數據顯示,如果有相同的incident_id和我的附加的圖像使用SQL:從狀態顯示防止數據

enter image description here

的pnt_id爲NULL。突出顯示的數據一定不能顯示

是否有可能?如果是這樣。誰能幫我。?並提前

+0

http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-詢問問題/ 285557#285557 –

+0

@a_horse_with_no_name其PHPMyAdmin(XAMMP) –

+0

@a_horse_with_no_name,如果我可以問嗎?你剛剛評論過的鏈接怎麼樣? –

回答

2

感謝嘗試此查詢:

SELECT respond_id, incident_id, pnt_id FROM TBL 
WHERE pnt_id IS NOT NULL 
UNION 
SELECT respond_id, incident_id, pnt_id FROM TBL 
WHERE incident_id in (SELECT distinct(incident_id) 
         FROM TBL 
         GROUP BY incident_id 
         HAVING count(id) = 1); 

聯合的第一部分將得到所有的NOT NULL pnt_ids ,第二部分將得到可能爲空的所有記錄,但走在結果。

聯盟合併兩個結果排除重複

+0

我在'where子句'中收到錯誤'未知列'pnt_id' –

+0

您確定發佈的列名稱是正確的嗎? 我用tbl作爲表名,因爲你沒有提供表名 – IvanM

+0

哥們對不起這是現在的錯誤。 ''having clause''中的未知列'respond_id'..我在表名 –