在此 SQL 语句中使用 SELECT 不起作用
我的表格是这样组织的:
以 key
作为主要字段。显示的记录位于renamed
表中。
我需要用钥匙取出original_name
。键列是表的主键。
这是我的 SQL 代码:
SELECT original_name FROM `renamed` WHERE key='fb166'
但是,它不返回任何结果。我已经通过我的 PHP 脚本和直接通过 phpMyAdmin 进行了尝试,并且都返回一个空结果集。
有什么帮助吗? :/
My table is organised like this:
With key
as the primary field. The records shown are in the renamed
table.
I need to get out the original_name
by the key. The key coluimn is the primary key of the table.
This is my SQL code:
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.
Any help? :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
key
是MySQL中的保留字。你有没有尝试过:key
is a reserved word in MySQL. Have you tried:尝试类似的操作
并检查您是否得到结果以及密钥的外观...
您是否得到以下结果?
Try something like
and check if you get a result and how the key looks like...
Do you get any results with the following?
反引号是必需的,因为 key 是 mysql 中的关键字。
按照建议,尝试使用
WHERE
keyLIKE '%fb166%'
因为您的列是文本类型,所以可能有其他字符在其中。拥有带有文本类型的键是一个坏主意,您将无法将其设为主键或向其添加索引。
The backticks are necessary as key is a keyword in mysql.
As suggested try with
WHERE
keyLIKE '%fb166%'
as you column is of type text it s probably you have some other char in it.It s a 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.