How can i delete a record and have one unique record per user. That means there could be multiple of the same records but by different users. one user can not have more than one of the same record.
For example if user 1 searches for spiderman movie, then that is a unique record, but if they search for spiderman again with the same name no difference then delete the second record. Now if user 2 searches for same spiderman movie then keep that record because the user id of user 2 is different than the user 1 so on so forth.
My question is how can i delete a user record and keep only one unique record per user.
I am using two different tables to track users and match them with the movie table
I would like to delete the movie that is not unique for a user in the user table and movie table.
here are my tables
https://i.stack.imgur.com/yrc97.png
DELETE FROM movie_media t1
USING accountMovie t2
WHERE id IN
(SELECT id
FROM
(SELECT id,
ROW_NUMBER() OVER( PARTITION BY title
ORDER BY id) AS row_num
FROM movie_media ) t
WHERE t.row_num > 1)
AND t2."accountId" = $1
im looking for something like this i know the code will not work im trying to convey my general idea of what im looking for