I have a java class that is supposed to display a table. So i want to search FROM table called Film the filmtitle and the film genre but the OR query doesn't work? any idea how to fix this?
heres my code btw
public void searchbyTitle()
{
String sql = "SELECT filmtitle, filmyear, filmgenre, companyname FROM production, film,
company WHERE LOWER(filmtitle) like LOWER
(?) OR LOWER(filmgenre) like LOWER (?) and production.companyid = company.companyid AND production.filmid = film.filmid";
con = DBConnect.getConnection();
try
{
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, "%" +txtSearch.getText()+"%");
ResultSet rs = pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
}catch(SQLException e)
{
e.printStackTrace();
}
}
it only works if i remove the or,but i also want to be able to search for film genre LOWER is also what i used so that it will be case insensitive also used postgresql..any help is appreciated