Okay so I have a table called posts and I am trying to remove the duplicates on the condition that if one of the post_id is equal to the post_dat_id and only remove it if post_data_id == post_id has a post_type of 2.
Posts Structure
post_id || post_data_id || post_type || post_user_id
==================================
1 || NULL || 0 || 10210
2 || 1 || 2 || 201020 <-- it shouldn't show this one because it meets the condition that post_type == 2 && the post_data_id is equal to one of the post_id. EDIT: also notice how this id = 2 but the post_data_id = 1. It is impossible for a row ot have the same post_id & post_data_id
2 || 1 || 0 || 202020
3 || 6 || 2 || 202020
My mysql:
SELECT p.*
FROM posts p
LEFT JOIN following f ON f.user_id =1
AND p.post_user_id = f.follower_id
WHERE post_user_id =1
OR f.user_id IS NOT NULL
ORDER BY `p`.`post_time` DESC
LIMIT 0 , 10
EDIT: I do not want to delete the code all I want to do is not show that result if the meet the criteria in my select. Also I am already using a left join because my sql code needs to check the following table to get the user id's
EDIT 2: I also changed the post_data to post_data_id so its a pure int now