I assume that you are using Mysql.
Mysql does not support subselects. What you are attempting is not possible with one query in MYSQL.
If it is not Mysql, then post the error you get.
OT: I don't see why you should do a right join in the subselect. And why id = (...) ? That would cause an error if the subselect returned more than one record.