DELETE FROM iwp_history WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
DELETE FROM iwp_history_additional_data WHERE historyID NOT IN ( SELECT historyID FROM iwp_history );
DELETE FROM iwp_history_raw_details WHERE historyID NOT IN ( SELECT historyID FROM iwp_history );
DELETE FROM iwp_site_stats WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
DELETE FROM iwp_user_access WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
DELETE FROM iwp_groups_sites WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
UPDATE iwp_sites SET adminUsername = 'todo' WHERE adminUsername = 'pronamic';
SELECT
s.siteID,
s.URL,
s.name,
s.adminUsername
FROM
iwp_sites AS s
LEFT JOIN
iwp_groups_sites AS gs
ON gs.siteID = s.siteID
WHERE
gs.groupID = 3
;