I have three tables
USER
---------------------------------------
id | uid | first_name | last_name | ...
---------------------------------------
0 | 95 | ... | ... | ...
1 | 100 | ... | ... | ...
2 | 120 | ... | ... | ...
3 | 130 | ... | ... | ...
NEWS_mm
------------------------
uid_local | uid_foreign
------------------------
40 | 90
40 | 100
50 | 120
50 | 130
NEWS
-------------------------------
id | uid | title | image | ...
-------------------------------
0 | 40 | ... | ... | ...
1 | 50 | ... | ... | ...
2 | 60 | ... | ... | ...
Now i want only select all users from table "USER" which have the news id 50 from table "NEWS". NEWS_mm has the news id (id_local) from "NEWS" and the user id (id_foreign) from "USER"
SELECT USER.*, NEWS_MM.*, NEWS.*
FROM USER
JOIN NEWS_MM
ON NEWS_MM.uid_foreign = USER.uid
JOIN NEWS
ON NEWS_MM.uid_local = NEWS_MM.uid_local
WHERE NEWS.uid = 50