我需要展示住在多个城市的员工 [英] I need to display the employee who is living in more than one city
本文介绍了我需要展示住在多个城市的员工的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的两张桌子中找到住在多个城市的员工
EMP_TABLE
------- ---
EMPID
EMPNAME
CITY_TABLE
-----------
EMPID
PLACE
< b>我尝试了什么:
我在上面的查询中有很多困惑,请任何人都可以给我一个上面的解决方案
Find employee who is living in more than one city in the below two tables
EMP_TABLE
----------
EMPID
EMPNAME
CITY_TABLE
-----------
EMPID
PLACE
What I have tried:
I have lot of confusion in above query,please can anyone give me a solution for above one
推荐答案
首先,建议在论坛中提问之前尝试一下。
您可以尝试类似的事情 -
First of all, would recommend to try something before asking question in the forums.
You can try something like-
SELECT EMPID,EMPNAME,COUNT(PLACE) AS NoOfPlaces
FROM EMP_TABLE E
LEFT JOIN CITY_TABLE C ON E.EMPID=C.EMPID
GROUP BY EMPID,EMPNAME
HAVING COUNT(PLACE)>1
希望,它有帮助:)
Hope, it helps :)
试试这个:
select * from emp_table e where exists ( select 1 from city_table c where c.empid=e.empid having count(*) > 1)
select e.empname from emp5 e inner join city b on e.empid=b.empid where e.empid
in(select empid from city group by empid having count(*)>1)
我给了两个不同的放置一个empid
如果我错了请纠正我。
I have given for two different places one empid
Please correct me if i am wrong.
这篇关于我需要展示住在多个城市的员工的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文