Hi all is it possible to rewrite query:
select userid from User where userid not in(select userid from UserRole where roleid in(8));
as Join?
the problem is that one user may have several roles
thank you in advance.
mysql> desc User; +--------------------+-------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+-------------------+------+-----+---------+----------------+ | userId | int(11) | NO | PRI | NULL | auto_increment | | userName | varchar(50) | YES | | NULL | |
...and other user related columns
mysql> desc UserRole; +--------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------+------+-----+---------+-------+ | userId | int(11) | NO | PRI | 0 | | | roleId | int(11) | NO | PRI | 0 | | +--------+---------+------+-----+---------+-------+