This question already has answers here:
MySQL Syntax error message “Operand should contain 1 column(s)”

(5 个回答)


6年前关闭。



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

并在 JSP 中获得以下异常
java.sql.sqlexception 插入操作数应包含 1 列

请帮忙。

最佳答案

正确的做法是

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

您可以为 where 子句保留 (),但不能保留在选择列表中。
这就是你的情况
mysql> select (firstname,email) from users limit 1 ;
ERROR 1241 (21000): Operand should contain 1 column(s)

关于mysql - 操作数应在java中包含1列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23239572/

10-11 01:34