I am trying to write my simple pet project using JDBC
Here is my prepared statement:
String query = "SELECT c.id as categoryId, c.`name`, p.id as productId, p.title, p.price, p.`status` FROM product p " +
"JOIN product_categories pc ON p.id = pc.product_id " +
"JOIN category c ON pc.category_id = c.id " +
"JOIN shop s ON c.shop_id = s.id " +
"WHERE s.`name` = ?";
PreparedStatement preparedStatement = conn.prepareStatement(query);
preparedStatement.setString(1, shop.getName());
preparedStatement.executeQuery(query);
However, I am getting every time this:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
What am i doing wrong?