当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式。 [英] Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

查看:76
本文介绍了当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是从下表中选择员工姓名多于一个电话号码

员工

empid

empname

mgrid





电话

empid

phno



在尝试执行查询时遇到以下错误。

My question is select the employee's name who's is having more than one phone numbers from below tables
employee
empid
empname
mgrid


Phone
empid
phno

while trying to execute the query getting below error.

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





我尝试过:





What I have tried:

<pre>select * from emp5 where empid in(select phnnumber,count(*) as dup from phone group by phnnumber having count(*)>1)

推荐答案

试试这个:
select * from employee e WHERE EXISTS (select count(*) from phone where e.empid=phone.empid having count(*)>1)


这篇关于当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆