Forum Moderators: open
OR
$query = "SELECT * FROM imei WHERE status=2 ORDER BY id DESC LIMIT 0, 500"
I have tried both, and im sure im still doing something wrong. Ive read for numerical values it should be the second one though thought id try to get some confirmation
Ive read for numerical values it should be the second one though thought id try to get some confirmation
Either should work (in mySQL, not sure about other database types.) You can quote queries on numeric fields but it is not required. IMO the confusion comes from working with PHP: when quoted, a variable's value is cast as a string type, without quotes, a numeric type - but this is in PHP, not mySQL. mySQL statements in PHP are still mySQL statements, and the select on a numeric field is still optional.
So if you're looping though a set of values in building a complex select, you need not make an exception to remove quotes on numeric fields. The two you posted should yield identical results.