Basically, I have a table of support users, and there are different user’s of different levels in different departments.
So let’s say I basically have the following table:
id | userID | deptID | level
1 1 1 1
2 119 1 2
3 2 1 3
4 101 2 1
5 104 2 2
And I have the id number, so let’s say, I want to get all users with the same deptID as the user in id:3, thus returning the first three lines.
What kind of SQL statement would that be?
You can use the following query, that contains a subquery: