此查询返回latitude = 0
和longitude = 0
SELECT `id`,
`first_name`,
`last_name`,
`address`,
`latitude`,
`longitude`
FROM `members`
WHERE (`temp` != 'on' OR `temp` IS NULL)
AND (`backup` != 'on' OR `backup` IS NULL)
AND (`latitude` IS NOT NULL OR `latitude` != 0 OR `latitude` != '')
AND (`longitude` != 0 OR `longitude` != '' OR `longitude` IS NOT NULL)
AND `address` != ''
AND `type_id` = 1
AND `first_name` != ''
查询返回lat / long有0值的行 - Datatype = VARCHAR
答案 0 :(得分:4)
您需要and
,而不是or
:
WHERE (`temp` != 'on' OR `temp` IS NULL)
AND (`backup` != 'on' OR `backup` IS NULL)
AND (`latitude` IS NOT NULL and `latitude` != 0 and `latitude` != '')
AND (`longitude` != 0 and `longitude` != ''and `longitude` IS NOT NULL)
AND `address` != ''
AND `type_id` = 1
AND `first_name` != ''
Latitude
可能为0(未通过该条件),但不是NULL
- 传递该条件。