这是到目前为止的查询:
select `formeid`, `name`, 'm' as `gender` from `data_pokemon`
where `genders` not like '0|_' and `formeid` not in
(select `formeid` from `dex` where `userid`=@userid and `gender`='m')
union
select `formeid`, `name`, 'f' as `gender` from `data_pokemon`
where `genders` not like '_|0' and `formeid` not in
(select `formeid` from `dex` where `userid`=@userid and `gender`='f')
union
select `formeid`, `name`, 'n' as `gender` from `data_pokemon`
where `genders`='0|0' and `formeid` not in
(select `formeid` from `dex` where `userid`=@userid and `gender`='n')
order by `formeid`
如您所见,有很多重复。有没有办法简化这个查询,所以没有那么多事情发生?