Select data and update a linked table

  • Hi,

    I am trying to update the table ‘contact’ and in the field ‘temp’ put a value of ‘on course’ with the results of this select query below. The link between the two tables are in the ‘contact’ table ‘edrs’ and in the ‘wce_course_delegate_link_2’ table ‘edrs_no’

    SELECT distinct edrs_no FROM wce_course_delegate_link_2 AS d INNER JOIN wce_contact AS c ON d.edrs_no = c.edrs where (d.end_date is null) and edrs_no <> ''

    I have tried several variations of update query and cannot seem to get the results I need.

    So this query below is logically what I want but not logical to SQL to give me the results i need. I’m thinking SQL is more logical than me so I could use some advice please 🙂 Thanks in advance.

    Update contact set temp = ‘on course’ where(SELECT distinct edrs_no

    FROM wce_course_delegate_link_2 AS d

    INNER JOIN wce_contact AS c ON d.edrs_no = c.edrs

    where (d.end_date is null) and edrs_no <> '')

  • here ya go...

    Update Contact

    Set Temp = 'on course'

    FROM wce_course_delegate_link_2 AS d

    INNER JOIN wce_contact AS c ON d.edrs_no = c.edrs

    where (d.end_date is null) and edrs_no <> ''

    --------------------------------------------------------------------------
    When you realize you've dug yourself into a hole....Step 1...stop digging.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply