2011-06-24 23 views
5

Spędziłem dobre godziny próbując naprawić ten.Co jest nie tak z tym SQL?

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

Co jest nie tak z tym?

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

Odpowiedz

19

Nie należy używać wycofań z wartościami kolumn. musisz użyć pojedynczych lub podwójnych cudzysłowów, w przeciwnym razie mysql uzna tę wartość za nazwę kolumny.

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

Co za głupi błąd. – Vercas

7

Zastosowanie pojedyncze cytaty zamiast znaków grawis dla `123.231.213.132``

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

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

3

Use quotes ' not backticks ` for string literals

2

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

1

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 itp