我有两个包含在UserID
之类的列上的表1. employee -------------------------------------------------------- id UserID Name Description 1 username1 fullName1 employee Description1 2 username2 fullName2 employee Description2 -------------------------------------------------------- 2. user_info -------------------------------------------------------- id UserID password 1 username1 password1 2 username2 password2 --------------------------------------------------------
我有user_info数据。我希望根据user_info数据雇用表行By" Subquery" 我想使用子查询语法
答案 0 :(得分:0)
我不知道你为什么只想要一个子查询,但试试这个,也许是有效的;)
select e.*
from employee e
where exists (
select 1 from user_info u
where e.UserID = u.UserID
)
-- maybe some conditions else need, you can add it by yourself
或者您也可以试试这个,
select e.*
from employee e
where e.UserID in (
select u.UseID from user_info u
)
无论如何,也许存在其他解决方案......