[英]Using SELECT in this SQL statement isn't working
My table is organised like this: 我的桌子是这样组织的:
With key
as the primary field. 以key
为主要字段。 The records shown are in the renamed
table. 显示的记录在renamed
表中。
I need to get out the original_name
by the key. 我需要通过密钥来获取original_name
。 The key coluimn is the primary key of the table. 键名称是表的主键。
This is my SQL code: 这是我的SQL代码:
SELECT original_name FROM `renamed` WHERE key='fb166'
However, it does not return any results. 但是,它不返回任何结果。 I have tried both through my PHP script and directly through phpMyAdmin and both return an empty result set. 我已经尝试通过我的PHP脚本和直接通过phpMyAdmin尝试,并且都返回一个空结果集。
Any help? 有什么帮助吗? :/ :/
key
is a reserved word in MySQL. key
是MySQL中的保留字。 Have you tried: 你有没有尝试过:
SELECT original_name FROM `renamed` WHERE `key`='fb166'
Try something like 尝试类似
SELECT '|' || key || '|'
FROM renamed
WHERE key LIKE '%fb166%'
and check if you get a result and how the key looks like... 并检查是否得到结果以及密钥的外观...
Do you get any results with the following? 您得到以下任何结果吗?
SELECT * FROM renamed
The backticks are necessary as key is a keyword in mysql. 反引号是必需的,因为key是mysql中的关键字。
As suggested try with WHERE
key LIKE '%fb166%'
as you column is of type text it s probably you have some other char in it. 如建议的那样,尝试使用WHERE
键,例如LIKE '%fb166%'
因为您的列是文本类型,可能是其中还有其他字符。
It sa bad idea to have a key with a type of text, you will not be able to make it a primary key or add an index to it. 具有文本类型的键是一个坏主意,您将无法使其成为主键或向其添加索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.