开发者

Basic MySQL problem

开发者 https://www.devze.com 2023-03-20 06:33 出处:网络
Why doesn\'t SELECT * FROM users_meta where user = 1 and key开发者_C百科 = tagline work? It works without the key = tagline. But I need that!

Why doesn't SELECT * FROM users_meta where user = 1 and key开发者_C百科 = tagline work?

It works without the key = tagline. But I need that!

users_meta is a table with these fields:

id, key, value, user.

I'm trying get the value from a row with key = tagline and user = 1.

Thanks!


It is because key is a MySQL keyword. If it is also a column name in your table, then you need to surround it in backticks. Like:

`key` = 'tagline'


Syntax. Backticks around reserved words used as identifiers, single quotes around string literals.

SELECT * FROM users_meta WHERE user = 1 AND `key` = 'tagline'
0

精彩评论

暂无评论...
验证码 换一张
取 消