首页 > 其他分享 >error:当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式

error:当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式

时间:2022-11-23 11:33:30浏览次数:48  
标签:emp EXISTS sal top 表达式 error where select desc

-- 报错代码
select top 3 *
	from emp
	where empno not in (select top 3 * from emp order by sal desc)
	order by sal desc

错误原因:如果要用in,后面 SELECT 必须能只能由一个列组成

-- 更正
select top 3 *
	from emp
	where empno not in (select top 3 empno from emp order by sal desc)
	order by sal desc;

如果是多列

select * from A where exists(
select b from tab where A.b = tab.B and A.b2 = tab.B2)

标签:emp,EXISTS,sal,top,表达式,error,where,select,desc
From: https://www.cnblogs.com/ce17091/p/16917718.html

相关文章