Let's imagine he have two tables
--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`phoneID` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Table structure for table `phone`
--
CREATE TABLE IF NOT EXISTS `phone` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userID` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
So now I need create such query - I need delete all phone-entries from phone table where userID not exist (means user was deleted from user table and there is no such userID) using only one query.
My thoughts: we can use innerJoin to select all equal entries and then somehow we need delete others from phone table.
Please help with it.
WBR