开发者

What is wrong with this SQL? [closed]

开发者 https://www.devze.com 2023-03-15 16:06 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. 开发者_如何学Go Closed 11 years ago.

I've spend good hours trying to fix this one.

SELECT * 
FROM  `users`
WHERE  `IP` = `123.231.213.132`

What is wrong with this?

#1054 - Unknown column '123.231.213.132' in 'where clause' 


You should not use backticks with column values. you have to use either single or double quotes otherwise mysql will consider that value as a column name.

SELECT * 
FROM  `users`
WHERE  `IP` = '123.231.213.132'


Use single quotes rather than backtick characters for `123.231.213.132``

SELECT * 
FROM  `users`
WHERE  `IP` = '123.231.213.132'


Use quotes ' not backticks ` for string literals


What's with the backticks? Use single quotes Also I'm assuming that users is a table name and IP is an entity of users.

Also...you have to end your statement with a semi-colon


It might be the single speach mark symbol. Try replacing them manually.


you are using wrong quotation characters

to specify string value in mysql statement you have to use either '(single quote) or "(double quote)

`(backtick) characters are used to explicitly specify that quoted string represents a field name from where mysql should get the data

backticks are required in your statements if column names are conflicting with mysql's reserved keywords like index, where, etc

0

精彩评论

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