php - Compare to tables in a mysql-database -
i've got 2 tables in mysql-database.
table "names":
id | name 100 | smith 136 | king 224 | brown 485 | miller
and second table "adresses":
name_id | adress 100 | mainstreet 11 101 | hiddleburger street 33 102 | great avenue 1022 103 | panorama avenue 687 ... | ...
in table "names" i've got 4 entries (id 100, 136, 224, 485). in table "adresses" i've got few hundret entries.
now want delete entries adresses have no matching names in table "names". want delete adress-entries, not name_id 100,136,224,485.
how can that? how can compare tables?
thank you!
not in , subquery. perhaps:
delete addresses name_id not in (select id names);
performance may not good, work.
Comments
Post a Comment