acil_farhat Posted February 26, 2022 Share Posted February 26, 2022 public int rechercheParCat(String test) { int idcat = 0; try { String query = "SELECT id_cat FROM categorie WHERE titre="+test; PreparedStatement pst = cnx2.prepareStatement(query); // pst.setString(1, test); ResultSet rs = pst.executeQuery(query); idcat = rs.getInt(1); } catch (SQLException ex) { System.err.println(ex.getMessage()); } return idcat; } } i have this erreur while i have Accessoires in table categorieas u can see in the pictures help me please output: 0 Unknown column 'Accessoires' in 'where clause' Link to comment Share on other sites More sharing options...
Ress Posted March 1, 2022 Share Posted March 1, 2022 Try like this: "SELECT id_cat FROM categorie WHERE titre='"+ test + "'"; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now