codenoob codenoob - 1 year ago 88
MySQL Question

mysql where clause resitriction?

I use below php code to generate a random id number

md5(uniqid(rand(), true)

the type of string it generate is something like this


I use that as an ID in Mysql table then I do a standard select query

SELECT * FROM table WHERE id = 9a423553ce53c4d7a6199fa9254bfdc5

I get this error

Unknown column '9a423553ce53c4d7a6199fa9254bfdc5' in 'where clause'

if I just change the id to a simple number like
it works.

Why is this?

Answer Source

Have you tried encapsulating that in quotes? In your query id = 9a423553ce53c4d7a6199fa9254bfdc5 You can compare two columns like id = other_id .. MySQL needs to know how to handle your query.

For clarification, should be: SELECT * FROM table WHERE id = '9a423553ce53c4d7a6199fa9254bfdc5';

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download