INSERT INTO Addr_Groups_Members SELECT g.id as grp_id, a.id as obj_id from Address_Groups as g, Addresses as a where g.name = "dummy" and a.name = "any"; INSERT INTO Addr_Groups_Members SELECT g.id as grp_id, a.id as obj_id from Address_Groups as g, Addresses as a where g.name = "dummy" and a.name = "localhost";