Why does this query return unwanted rows

Angad Dubey

This query returns rows with latitude = 0 and 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` != ''

query is returning rows where lat/long have 0 value - Datatype = VARCHAR

Gordon Linoff

You want and, not 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 may be 0 (failing that condition), but it is not NULL -- passing that one.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does this XQuery filter return unwanted elements?

From Dev

Why does my SQL query return no rows, when sum is 0

From Dev

Why does this query return no results?

From Dev

Why does this query return no results?

From Dev

Why does this Query return NULL?

From Dev

When does a SELECT query begin to return rows?

From Dev

Why does my SQL query != "Some Value" not return any rows where NULL?

From Dev

Why does my SQL query != "Some Value" not return any rows where NULL?

From Dev

Why does this group by statement return no rows?

From Dev

MySQL query does not return all available rows in a simple query

From Dev

Why exactly does this Lucene query return no hits?

From Java

Why does a GraphQL query return null?

From Dev

Why does not this DL query return expected results?

From Dev

Why does this dapper query return null?

From Dev

Why does this MySQL XOR query return 0?

From Dev

Why does this query always return ALL records?

From Dev

<> or NOT IN, and why does query return wrong results

From Dev

Why does this query return nil from Firestore

From Dev

Why does this MySQL XOR query return 0?

From Dev

Why Does This Query Return Items from 2013?

From Dev

Why does this MongoDB aggregate query return nothing?

From Dev

Why does the LINQ query return no element?

From Dev

Why does COUNT(*) in my SQL query return several values? How to get one single value for total rows found?

From Dev

Why Does SQL Query of >= '5/1/2018' and <= '5/1/2018' only return rows of 2018-05-01 00:00:00?

From Dev

Why does xPath query does not return correct output?

From Dev

Why does group by statement do not return correct rows?

From Dev

Why does np.median() return multiple rows?

From Dev

Why does my postgresql SELECT statement return 0 rows?

From Dev

Why does this prepared statement always return -1 rows affected?

Related Related

  1. 1

    Why does this XQuery filter return unwanted elements?

  2. 2

    Why does my SQL query return no rows, when sum is 0

  3. 3

    Why does this query return no results?

  4. 4

    Why does this query return no results?

  5. 5

    Why does this Query return NULL?

  6. 6

    When does a SELECT query begin to return rows?

  7. 7

    Why does my SQL query != "Some Value" not return any rows where NULL?

  8. 8

    Why does my SQL query != "Some Value" not return any rows where NULL?

  9. 9

    Why does this group by statement return no rows?

  10. 10

    MySQL query does not return all available rows in a simple query

  11. 11

    Why exactly does this Lucene query return no hits?

  12. 12

    Why does a GraphQL query return null?

  13. 13

    Why does not this DL query return expected results?

  14. 14

    Why does this dapper query return null?

  15. 15

    Why does this MySQL XOR query return 0?

  16. 16

    Why does this query always return ALL records?

  17. 17

    <> or NOT IN, and why does query return wrong results

  18. 18

    Why does this query return nil from Firestore

  19. 19

    Why does this MySQL XOR query return 0?

  20. 20

    Why Does This Query Return Items from 2013?

  21. 21

    Why does this MongoDB aggregate query return nothing?

  22. 22

    Why does the LINQ query return no element?

  23. 23

    Why does COUNT(*) in my SQL query return several values? How to get one single value for total rows found?

  24. 24

    Why Does SQL Query of >= '5/1/2018' and <= '5/1/2018' only return rows of 2018-05-01 00:00:00?

  25. 25

    Why does xPath query does not return correct output?

  26. 26

    Why does group by statement do not return correct rows?

  27. 27

    Why does np.median() return multiple rows?

  28. 28

    Why does my postgresql SELECT statement return 0 rows?

  29. 29

    Why does this prepared statement always return -1 rows affected?

HotTag

Archive