MySQL SELECT 字段小于和大于值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15865151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL SELECT with fields less and greater than values
提问by Hristo
I am trying to do a select query on MySQL with phpMyAdmin or PHP with PDO.
我正在尝试使用 phpMyAdmin 或 PHP 使用 PDO 对 MySQL 进行选择查询。
SELECT 'uid' FROM 'clusters' WHERE 'lat'<='47.21125' AND 'lat'>='39.21125' AND 'lng'<='32.90243' AND 'lng'>='22.90243'
However, phpMyAdmin says:
但是,phpMyAdmin 说:
#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?
它有什么问题?
回答by Explosion Pills
''
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)
''
在 MySQL 中创建一个字符串文字,因此您的查询是从文字“clusters”中选择文字“uid”,这是无效的。使用 backtics(或什么都不使用)
SELECT Uid FROM clusters WHERE lat <= 47.21125 AND lat >= 39.21125
AND lng >= 22.90243