mysql5 - Mysql Query On Joins -
i have 2 tables
table1
sno receiver user1 user2 1 133 44 45 2 144 66 77 3 155 77 33
and
table 2
receiver user 133 44 133 45 144 88 144 55 155 77
required : delete rows table1 not have matching entry in table2
example
2 144 66 77
shoul deleted there no row of 144 66 on table2
155 33
i tried not working delete table1 left join table2 b on (a.receiver=b.receiver , a.user1=b.user) , b.user null;
you can use join inside delete statement, too. following statement joins (using left join!) 2 tables, selects result rows have no corresponding record table 2 (where ...) , deletes respective rows t1:
delete t1 t1 left join t2 on (t1.receiver = t2.receiver , t1.user1 = t2.user) t2.receiver null
see manual reference, "multi-table deletes" section.
Comments
Post a Comment