Skip to main content
Known Participant
August 4, 2011
Question

copying between multiple tables

  • August 4, 2011
  • 1 reply
  • 565 views

I have some records in tables A  with fields i.e firstname surname, lastname, school, dob

I have another table B with some records and fields i.e firstname, surname, address, club,

There are some records in table B which exists in table A

I'd like to use the firstname and surname in table B to check if the record exist in table A.

if it doesnt it should append the record to table A.

I would be glad if you can help me with this

This topic has been closed for replies.

1 reply

Inspiring
August 4, 2011

INSERT INTO TableA (firstname, lastname .......)

SELECT

     firstname

     , lastname

     , ...

FROM

     TableB

WHERE NOT EXISTS (

     SELECT *

     FROM TableA

     WHERE

          TableA.firstane = TableB.firstName

          AND TableB.lastName = TableA.lastName

)