I wanted to get more than one id from the bank, since I can only pull one. I think it must be the syntax that is wrong. '
$sql = "SELECT * FROM camiseta_Masc WHERE id =1,2,3";
'
I wanted to get more than one id from the bank, since I can only pull one. I think it must be the syntax that is wrong. '
$sql = "SELECT * FROM camiseta_Masc WHERE id =1,2,3";
'
Yes, it is syntax error.
One solution is this:
$sql = "SELECT * FROM camiseta_Masc WHERE id IN (1,2,3)";
See working in SQL FIDDLE .
Errors of this nature can be solved by reading the language manual.
If there was no IN
:
$sql = "SELECT * FROM camiseta_Masc WHERE id=1 OR id=2 OR id=3";
See working on SQL FIDDLE .
Just curious, IN
could be used "backwards" if you wanted to find a value in more than one field instead of more than one value in a field:
SELECT nome WHERE 3107 IN ( codigo, codigo_master );