I have Group and each group has contacts associated with it. When a user deletes a group, if the group is not empty then it will alert them that all contacts in that group will be deleted if they continue. Well anyways, so my problem is setting up that feature.
I have tried to figure out how I can delete all contacts that belong to that group and delete the group as well.
Before I continue I'm wondering but is there a sorta of automated way of doing this via foreign keys?
Well if not its ok, this is my query but SQL Workbench is throwing out the following error
DELETE c
FROM `list_`.`contacts` AS c
INNER JOIN `list_`.`groups` AS g ON c.group_id = g.id
WHERE g.group = 'School'
AND c.user_id = 2;
error:
Error Code: 1046 No database selected
really confused here, also I have also tried c.*