How to solve this SQL syntax error problem?
P粉409742142
P粉409742142 2023-09-06 21:08:29
0
1
462

I encountered an error with the server regarding a request to the database.

This is the error message:

java.sql.SQLSyntaxErrorException: There is an error in your SQL syntax; check the manual for your MySQL server version for ', Regione='e', provincia='q', comune= on line 1 Correct syntax to use around 'w''

This is the SQL query in question:

PreparedStatement ps = con.prepareStatement("SELECT * FROM azienda WHERE id_categoria=?, 
regione=?, provincia=?, comune=?");
        ps.setInt(1, id);
        ps.setString(2, regione);
        ps.setString(3, provincia);
        ps.setString(4, comune);

Thanks in advance!

P粉409742142
P粉409742142

reply all(1)
P粉135799949

If you use multiple conditions, try using AND:

SELECT * 
FROM azienda 
WHERE id_categoria=? 
AND regione=? 
AND provincia=? 
AND comune=?
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template