Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003

    Unanswered: help with complex delete


    I need to delete all records from the group-ids associated with metagroup_id=28 who are contact_type='members'. I'm trying the query below but it won't work. Hoping someone can shed some light?

    DELETE FROM groupContacts
    WHERE contact_id IN
    SELECT c.contact_id
    FROM contacts c INNER JOIN
    SELECT c.contact_id, c.contact_type, c.fname, c.lname, c.school_id, c.permanent_address_1
    FROM contacts c INNER JOIN groupContacts gc ON c.contact_id=gc.contact_id
    INNER JOIN groups g ON gc.group_id = g.group_id
    INNER JOIN groupMetagroups gmg ON gmg.group_id=g.group_id
    INNER JOIN meta_groups mg ON mg.metagroup_id = gmg.metagroup_id
    WHERE mg.metagroup_id = 28
    AND (c.contact_type = 'prospect')
    ) AS DrvTbl
    ON DrvTbl.fname = c.fname
    AND DrvTbl.lname = c.lname
    AND DrvTbl.school_id = c.school_id
    AND (SUBSTRING(ltrim(rtrim(DrvTbl.Permanent_Address_1) ),1,5) = SUBSTRING(ltrim(rtrim(c.Permanent_Address_1)),1,5) )
    WHERE c.contact_type='member'
    AND group_id IN (select group_id from groupMetagroups where metagroup_id = 28)

  2. #2
    Join Date
    Mar 2003
    nm, i figured it out

  3. #3
    Join Date
    Jan 2004
    In a large office with bad lighting
    OK, consider yourself never minded

    -- This is all just a Figment of my Imagination --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts