sync lead project
-- sycn data project UPDATE projects SET agent_id = ( SELECT id FROM agents WHERE is_pic = true AND agents.office_id = projects.office_id LIMIT 1 ) WHERE agent_id is null; update agents set is_pic = true where email in (select email from projects); update leads set agent_id = ( SELECT id FROM agents WHERE is_pic = true AND agents.office_id = leads.office_id LIMIT 1 ) where project_id is not null; -- sync data unit update advertises set agent_id = ( SELECT agent_id FROM projects WHERE projects.id = advertises.project_id LIMIT 1 ) where advertises.project_id != 0; update leads set agent_id = ( SELECT agent_id FROM advertises WHERE advertises.id = leads.ads_id LIMIT 1 ) where project_id is null;
Leave a Comment