2014-06-11 47 views
-1

我的MySQL查詢是相當複雜的,我想從它如何刪除我在下面複雜的MySQL查詢空列

SELECT NamazTiming.FajarZamat,MasjidMaster.MasjidID_PK,MasjidMaster.MasjidName,MasjidMaster.Longitude,MasjidMaster.Latitude,MasjidMaster.Address, 
    SQRT(POW(69.1 * (MasjidMaster.Latitude - 19.8) , 2) + POW(69.1 * (75.4- MasjidMaster.Longitude) * COS(MasjidMaster.Latitude/57.3) , 2)) AS distance ,CityMaster.CityName 
    FROM MasjidMaster 
    LEFT JOIN CityMaster 
    ON MasjidMaster.CityID_FK = CityMaster.CityID_PK 
    LEFT JOIN NamazTiming 
    ON MasjidMaster.MasjidID_PK = NamazTiming.MasjidID_FK 
    HAVING distance < 10 
    ORDER BY NamazTiming.FajarZamat 

的空列刪除空列NamazTiming.FajarZamat

+1

您既可以從選擇列表中刪除列,也可以用'IFNULL(ColumnName,'defaultValue')'語句包裝這些列。 –

+0

「刪除空列」使得值不爲空或「刪除空列」,如「不返回列____爲空的記錄」一樣? –

回答

0

我相信你應該在ORDER BY之前將以下內容添加到你的查詢中。這將刪除該列爲空的所有行。

WHERE NamazTiming.FajarZamat IS NOT NULL 
+0

,有一點修改+ – user3671032