From multiple tables mysqli need to select the data and simply access them when displaying my code almost does everything right, but there is a drawback how to fix?

there is a query in the database which selects the data from the users and joinem pulls several tables phone_number, email, countries.
SELECT users.id users.name, users.soname, users.adress ,users.zip_city countries.name as country, GROUP_CONCAT(DISTINCT phone_number.phone_number SEPARATOR '
') as phone_number , GROUP_CONCAT(DISTINCT email.email SEPARATOR '
') as email
FROM users
RIGHT JOIN (SELECT id, user_id, status, phone_number FROM phone_number WHERE phone_number.status = "1") phone_number ON phone_number.user_id=users.id
RIGHT JOIN (SELECT id, user_id, status, email FROM email WHERE email.status = "1") email ON email.user_id=users.id
JOIN countries ON countries.id=users.country_id
GROUP BY users.id
ORDER BY users.id DESC
The problem is that when he selects these data the values of which are in the table but the email is not in the table phone_number he chooses and Vice versa only if the data is there and there then he chooses them. I think the problem may be with the gang? if you take away one of the tables email or phone_number then runs fine.
March 19th 20 at 08:44
1 answer
March 19th 20 at 08:46
Solution
Read what is the difference between a RIGHT JOIN from LEFT JOIN and INNER JOIN

Find more questions by tags MySQL