简体   繁体   中英

mysql clause where not null in php

I am making a query which is not working. I want to get data where column of pic in is not empty in all_destination table, also I am using join in my query:

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

whats wrong in my query?

You should check what is the error returned by MySQL. It will tell you what is the error.

You just want to remove the IS NOT NULL check and just have

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

This will only return records where all_destination.pic has been set.

try this:

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

您可以尝试一下。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM