Hey All,
I wish to SET contacts.cycle= the COUNT of all emails (sent) in my emails table
WHERE emails.parent_id = contacts.id
AND contacts.invalid_email !=1 (contact email address is valid)
I've cobbled togehter the following query which works --- ALBEIT VERY SLOWLY --
but I'm thinking there MUST BE a better way to get the job done????
UPDATE contacts AS a INNER JOIN (SELECT emails.parent_id AS p_id,
COUNT( * ) AS count
FROM emails, contacts
WHERE emails.parent_id = contacts.id
AND contacts.invalid_email !=1
AND emails.deleted !=1
GROUP BY p_id) AS a_c
SET a.cycle = count, a.date_modified= NOW()
WHERE a.cycle != count
AND a.id= p_id