I have been using 2 tables like this
tbl_songs
id | track_id | dummy_name
tbl_tracks 
id | song_id
I have duplicate dummy_name but my first record's value from set of duplicate records is updated to tbl_tracks like this.
tbl_songs s
id | track_id | dummy_name
 1 |       12 | A
 2 |          | A
 3 |          | A
 4 |      2   | B
 4 |          | B
tbl_tracks t
 id | song_id 
 2  | 4
 12 | 1
By Inner join relationship I have updated tbl_songs 's track_id column to find the duplicate records..
NOTE I want to delete those records that are with same dummy_name (i.e duplicate recods) and have track_id = '' or I can say that are not related with tbl_tracks.
My tried sql for selecting records
SELECT a.id as aid, a.dummy_name as adn, b.id as bid, b.dummy_name as bdn
FROM tbl_songs a
LEFT JOIN tbl_songs b ON a.dummy_name = b.dummy_name
WHERE a.track_id != '' AND  a.dummy_name != '' AND a.id <> b.id
To delete these records
DELETE FROM tbl_songs where EXISTS (
SELECT *
FROM tbl_songs a
LEFT JOIN tbl_songs b ON a.dummy_name = b.dummy_name
WHERE a.track_id != '' AND  a.dummy_name != '' AND a.id <> b.id)
Error: You can't specify target table 'tbl_songs' for update in FROM clause
 
     
    