Removing unwanted NULL results when using Right join
This is a job for INNER JOIN, not RIGHT JOIN.  

Inner joins give results only when there is a match in both tables.  Right and left joins give results for all rows in either the right-side table or the left-side table with NULL values in columns from the joined table when there is no match.

Here's a an example to help visualize it:

mysql&gt; select * from a;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
|    4 |
|    5 |
+------+
5 rows in set (0.01 sec)

mysql&gt; select * from b;
+------+
| id   |
+------+
|    3 |
|    4 |
+------+
2 rows in set (0.00 sec)


With the INNER JOIN, only rows with matching values of the "id" column in both tables are returned:

mysql&gt; select a.id, b.id from b inner join a on (a.id = b.id);
+------+------+
| id   | id   |
+------+------+
|    3 |    3 |
|    4 |    4 |
+------+------+
2 rows in set (0.00 sec)


With the right join, all the rows from table "a" are returned, with NULL for the values from table "b" when there is no matching row in "b":

mysql&gt; select a.id, b.id from b right join a on (a.id = b.id);
+------+------+
| id   | id   |
+------+------+
|    3 |    3 |
|    4 |    4 |
|    1 | NULL |
|    2 | NULL |
|    5 | NULL |
+------+------+
5 rows in set (0.00 sec)


If you really, really insist on using RIGHT JOIN for this, suppress the rows with NULL values by using WHERE.  Example:

mysql&gt; select a.id, b.id from b right join a on (a.id = b.id) WHERE b.id is not null;
+------+------+
| id   | id   |
+------+------+
|    3 |    3 |
|    4 |    4 |
+------+------+
2 rows in set (0.00 sec)