2016-12-16 83 views
1

我正在進行一個不工作的查詢。我想獲得的數據,其中在PIC的列不爲空在all_destination表,還我使用加入我的查詢:mysql子句在php中不爲空

SELECT * 
FROM `travels_detail` 
INNER JOIN all_destination ON travels_detail.destination = all_destination.destination 
WHERE all_destination.pic IS NOT NULL 

什麼是錯我的查詢?

+0

究竟是不是工作?請提供更多詳細信息 –

+0

是什麼錯誤? –

回答

0

你應該檢查MySQL返回的錯誤是什麼。它會告訴你什麼是錯誤。

+0

它沒有給我錯誤。它給我的結果還包括列(pic)的空值,這是我不需要的。 –

+1

所以你的查詢正在工作......但結果不是你所期望的。你應該用提供的新細節更新你的問題(空值包含在結果中) – Thomas

+0

我如何編輯我的問題? –

0

你只是想刪除的IS NOT NULL檢查,只是有

SELECT * 
FROM `travels_detail` 
INNER JOIN all_destination ON travels_detail.destination = all_destination.destination 
WHERE all_destination.pic; 

這隻會返回其中all_destination.pic已設置的記錄。

+0

其刪除不爲空後給我0結果 –

+0

您使用@HarrisKhan的MySQL版本是什麼?另外,我可以從表格中看到您希望看到/未看到的一些記錄嗎? –

0

試試這個:

SELECT td.some_attribute 
FROM travels_detail as td 
INNER JOIN all_destination as ad ON td.destination = ad.destination 
WHERE ad.pic IS NOT NULL 
0

你可以試試這個。它主要是適用

SELECT * FROM `travels_detail` INNER JOIN all_destination ON travels_detail.destination = all_destination.destination WHERE all_destination.pic ! = ""