Reputation: 27
I have a quizzes table where I store the name of the test and the question, and I want the user(teacher) to enter a word in a Jtextfield, and the program to show all the questions which contain the given word. I tried using the LIKE operator from SQL, it produces no error but also doesn't show any output.
ResultSet rs = stmt.executeQuery("SELECT * FROM quizzes WHERE testName =\"" +
testName + "\" AND question LIKE '%\""+ word + "\"%';");
Have I written something wrong?
Upvotes: 0
Views: 478
Reputation: 48770
Fix the following things:
It should look like:
ResultSet rs = stmt.executeQuery("SELECT * FROM quizzes WHERE testName ='" +
testName + "' AND question LIKE '%"+ word + "%'");
Upvotes: 2