SQL Server 2014显示错误

时间:2017-11-30 07:15:14

标签: sql sql-server select subquery

set @return=(SELECT u_id,u_pass from m_User where u_id = @userName AND u_pass=@userPass);

显示类似这样的错误

"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."

1 个答案:

答案 0 :(得分:1)

您无法在子查询中选择多个列。 在这里,您要选择两列u_id,u_pass

根据需要只选择一个。

如果@return属于数据类型(例如,varchar,int)

set @return=(SELECT u_id from m_User where u_id = @userName AND u_pass=@userPass);

set @return=(SELECT u_pass from m_User where u_id = @userName AND u_pass=@userPass);