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

    Unanswered: How to insert value without duplicated

    Hello, everyone:

    There is a table MyTable,
    A B
    a c
    b k
    mk oc

    How to insert from another table, YourTable,
    C D
    d c
    e p
    mk oc

    without duplicate value such as third row?

    Thanks a lot


  2. #2
    Join Date
    Jun 2003
    Provided Answers: 1
    Some people use WHERE NOT EXISTS, but I suspect that this method is more index-friendly:

    insert into MyTable (A, B)
    select C, D
    from YourTable
    left outer join MyTable on YourTable.A = MyTable.C and YourTable.B = MyTable.D
    where MyTable.A is null
    If it's not practically useful, then it's practically useless.

    blindman "sqlblindman"

Posting Permissions

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