Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with this SQL? [closed]

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' 
like image 774
Vercas Avatar asked Jun 24 '11 10:06

Vercas


People also ask

What is the purpose of the SQL as close?

The AS command is used to rename a column or table with an alias. An alias only exists for the duration of the query.

Why is SQL query suspended?

It means that the request currently is not active because it is waiting on a resource. The resource can be an I/O for reading a page, A WAIT it can be communication on the network, or it is waiting for lock or a latch. It will become active once the task it is waiting for is completed.


2 Answers

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'
like image 90
Shakti Singh Avatar answered Oct 20 '22 00:10

Shakti Singh


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

SELECT * 
FROM  `users`
WHERE  `IP` = '123.231.213.132'
like image 24
Sarfraz Avatar answered Oct 19 '22 22:10

Sarfraz