I'm trying to turn the following SQL query into a view.
SELECT * FROM system_accounts
WHERE system_accounts.id
NOT IN (SELECT account_id
FROM system_group_members
WHERE system_group_members.group_id = 1);
In other words, how do I go about creating a view that gives me all the non-members of a certain group, with those non-members coming from the total set of accounts known to the system?
The query works fine when I test it in my Adminer window. However, I'm at a loss how to express the variable group_id (which in my example is '1') in correct SQL for a view.
I'm sure I'm missing something trivial, but this is the sort of thing I'll bang my head on for hours. Hopefully some kind soul here will help me out.
Many thanks for your time.