阅读背景:

MySql: How to check field has data in MySql?

来源:互联网 

Here is my code and result :

这是我的代码和结果:

SELECT DISTINCT
    CAL.CarListingId,
    (SELECT 
           IF(REPLACE(carImage.ImageUrl,'~','') IS NULL,'asdf',REPLACE(carImage.ImageUrl,'~',''))

        FROM
            carImage
        WHERE
            IsMainImage = 1 AND Status = 1
                AND CarListingId = CAL.CarListingId) AS ImageUrl,
    CAL.ListingNumber,
    CAL.Caption,
    CAL.Year,
    CAL.Km,
    CAL.Color,
    CAL.Price,
        CONCAT((SELECT Name FROM City WHERE CityId IN (SELECT CityId FROM County WHERE CountyId = CAL.CountyId)),'/', (SELECT Name FROM County WHERE CountyId = CAL.CountyId)) AS Region,
    CAL.Creation

FROM
    carlisting AS CAL
        INNER JOIN
    User AS U ON U.UserId = CAL.CreatedBy

INNER JOIN
    carlistingcategory AS CLC ON CLC.CarListingId = CAL.CarListingId
LEFT JOIN CarImage AS CI ON CI.CarListingId = CAL.CarListingId

ORDER BY CAL.Creation;

I use this query as a subquery in another query. I need to check this query's result if it is `NULL`. But as you can see there is no data so `IS NULL`  returns false. How can I check the sub query has data ?
SEL



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: