SELECT id FROM user WHERE id IN ( 2,3,4,7,9,21,23,45,324,12,43,254 ) UNION SELECT DISTINCT user_id FROM workgroup_users WHERE workgroup_id IN ( 1,345,34,654,213,123,5,2,3,4 )
I know we should not use the
IN clause because it degrades performance in index columns.
user and users which belong to one of the listed workgroups. Below are the table structures:
workgroup_users user_id workgroup_id user id username