I admit the title question is convoluted; here is the situation.
I have two tables:
USERS Table
| id | name | status |
|---|---|---|
| 1 | Monica | A |
| 2 | Ross | A |
| 3 | Phoebe | T |
| 4 | Chandler | A |
| 5 | Rachel | T |
| 6 | Joey | A |
PERMISSIONS Table
| user_id | permission_id |
|---|---|
| 1 | 32 |
| 1 | 51 |
| 4 | 12 |
| 6 | 2 |
| 3 | 5 |
| 5 | 22 |
| 2 | 18 |
What I want is a way to delete all rows from the PERMISSIONS table where that user's STATUS is "T" but how would I do that?
I had tried this:
DELETE FROM permissions
WHERE user_id IN (
SELECT id FROM users
WHERE status = 'T'
);
However, SQL Server gives this error: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.