Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operand should contain 1 column(s) in java [duplicate]

String  sql = "SELECT (Employee_name, Password) FROM employee WHERE (Employee_name = '"+name+"'  AND Password = '"+password+"')";

and getting the following exception in JSP java.sql.sqlexception insert operand should contain 1 column(s)

Please help.

like image 671
user3507176 Avatar asked Mar 20 '23 19:03

user3507176


1 Answers

Correct way is

String  sql = "SELECT Employee_name, Password FROM employee WHERE Employee_name = '"+name+"'  AND Password = '"+password+"'";

You can keep () for where clause but not in select list. This is what happens in your case

mysql> select (firstname,email) from users limit 1 ;
ERROR 1241 (21000): Operand should contain 1 column(s)
like image 184
Abhik Chakraborty Avatar answered Apr 07 '23 18:04

Abhik Chakraborty