Could you tell me how to realize this function with SQL?

first of all, I want to query the department to which the user belongs

select * from dept where id in (select deptId from employee where id="00")

the above statement is not good. If you want to achieve such a result, how can you use SQL statement to achieve such a function?

Dec.31,2021

SELECT b.* FROM employee a, dept b WHERE a.id = '00' AND FIND_IN_SET(b.id, a.deptId) 

FIND_IN_SET is a function of mysql . Other databases are not applicable

.

sqlserver it seems that the same effect can be achieved through the CHARINDEX function, but there is no environment test

.
Menu