Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL SELECT with fields less and greater than values

I am trying to do a select query on MySQL with phpMyAdmin or PHP with PDO.

SELECT 'uid' FROM 'clusters' WHERE 'lat'<='47.21125' AND 'lat'>='39.21125' AND 'lng'<='32.90243' AND 'lng'>='22.90243'

However, phpMyAdmin says:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''clusters' WHERE 'lat'<='47.21125' AND 'lat'>='39.21125' AND 'lng'<='32.90243' A' at line 1

What is wrong with it?

like image 301
Hristo Avatar asked Apr 07 '13 17:04

Hristo


1 Answers

'' creates a string literal in MySQL, so your query is selecting the literal "uid" from the literal "clusters," which is invalid. Use backtics (or nothing)

SELECT Uid FROM clusters WHERE lat <= 47.21125 AND lat >= 39.21125
AND lng >= 22.90243
like image 194
Explosion Pills Avatar answered Nov 20 '22 02:11

Explosion Pills