select and insert only one row where duplicates exist

  • Hi,

    I need to insert into one table from another. The problem is the unique key in the source table (ilr.learning_aim) is unique to a learners records but there will be multiple instances of the this key as a learner can be on several courses. This is the only unique key i have in the data and i can't use an auto number.

    If i could find a way to take one instance where the ilr.learning_aim exists and insert that into the wce_contact i will get the desired result.

    Is there anything i can add to the query to say select only one row where the unique key exists?

    Thanks for any help

    INSERT INTO wce_contact (

    UNIQUEID,

    contact,

    firstname,

    lastname,

    middlename

    )

    SELECT

    ilr.learning_aim,

    ilr.student_name,

    ilr.forename,

    ilr.surname,

    ilr.middle_names

    FROM wce_ilr ilr

  • Hi,

    use the distinct in the source table

    ARUN SAS

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

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