我有两个 table 包含在与 UserID 相同的列中。如何通过子查询获取所有行

i have tow table which contain on same column like UserID. How to get all row by subquery

我有两个 table 包含在与 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 数据 "Subquery" 员工 table 行 只是我想使用子查询语法

我不知道你为什么只想要一个子查询,但试试这个,也许有用;)

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
)

无论如何,也许存在其他解决方案...