Jump to content

SQL insert and update

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Caspersky12

Caspersky12

    Newbie

  • Members
  • Pip
  • 6 posts
Is there any1 can help me to my lines
ex...

Table 1
Acct_Num Name
123456 Mhel
123465 Jhen

Table2
Acct_Num Name
123456 Mhel
125555 Jenny
133455 Led

I want to insert the record not listed in the Table 1 e.g(125555, Jenny and 133455, Led) but, the problem is Table 2 has an existing record from Table1...

Insert into Table1(Acct_Num, Name) Select Acct_Num,Name from Table2 where not exists(Select Acct_Num, Name from Table1)

tnx, i highly appreciated those who want to give some help...

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I don't understand what you are asking. From what I see you are trying to insert 125555 and Jenny but a record already exists? You can use "delete" to remove the record:

DELETE FROM tb1 WHERE Acct_Num="125555";

And then run your insert command. Not sure what you are trying to do though.