Hello,
With my current code i can search on either first name or last name in my database, but im wondering if anyone could explain how i can compare the input to firstname + lastname.
Further explanation:
i search for Vincent, it shows all people with the name Vincent. <-- works
i search for lastNa, it shows all people with the lastname lastNa. <-- works
Now i need to make it so, that when i enter '' Vincent lastNa''' it shows everyone with that fullname.
private void nameSearch() {
searchBarN = zoekS.getText();
try {
Statement stat = conn.createStatement();
DefaultListModel spelerlijst = new DefaultListModel();
ResultSet result = stat.executeQuery("SELECT * FROM player WHERE firstname LIKE '%" + searchBarN + "%' OR lastname LIKE '%" + searchBarN + "%'");
ModelItem item;
while (result.next()) {
item = new ModelItem();
item.id = result.getInt("spelerID");
item.description = result.getString("firstname") + " " + result.getString("lastname ");
spelerlijst.addElement(item);
}
list_speler.setModel(spelerlijst);
} catch (SQLException | NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Kan deze naam niet vinden");
} catch (NullPointerException e) {
}
}
many thanks in advance,
Vincent