Hey, i need to take just one element from my database table. I have this table - Users. and it has ID, Login, Password and Surname. I want to take just surname from this table. Something like ("Select Surname from Users where login =")
Im trying to use this, but it gives me errors saying this ("Unkown column 'Admin' in 'where clause'"):
private void whoslogedinLabel(){
String sql = "select Surname from Users where login = Admin";
try {
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
logininfoLabel.setText(sql);
}
catch (Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
logininfoLabel - is the label where i want the Surname to be displayed