php mysql I tray to join 3 table but in show duplicated result

Solution:

The join condition that brings in table groups needs to be fixed.

You have:

SELECT ...
FROM group_not 
JOIN groups ON group_not.group_id = $group_id   --> here
JOIN notifications ON group_not.not_id = notifications.not_id 
WHERE group_not.group_id = $group_id

While you actually need:

JOIN groups ON group_not.group_id = groups.group_id

I would also recommend using table aliases to make the query easier to read and write. You should also use a parameterized query rather than concatenating the variable in the query string. So:

SELECT gn.group_not_id, n.not_name, g.group_name 
FROM group_not gn 
INNER JOIN groups g ON gn.group_id = g.group_id
JOIN notifications ON gn.not_id = n.not_id 
WHERE gn.group_id = ?

Answer

Solution:

I suggest you to use SELECT DISTINCT AS BELOW:

SELECT DISTINCT group_not.group_not_id, notifications.not_name, groups.group_name FROM group_not JOIN groups ON group_not.group_id = $group_id JOIN notifications ON group_not.not_id = notifications.not_id WHERE group_not.group_id = $group_id";

The SELECT DISTINCT statement is used to return only distinct (different) values.

Source