Hi guys! I'm currently making an integration of 2 different web apps. I would to ask if is it possible to restrict adding duplicate data in your table.
for Example
i have two different tables from two different databases.

App1_Invoice (from Web App 1 database)

App2_Invoice (from Web App 2 database)

I will Insert App1_Invoice.transno to App2_Invoice.transno
and so on so forth.

(I can't alter the App2_Invoice Table. it might ruin the whole Web App2)
but anyway, Is there any way in SQL to restrict that?! since the Primary key for App2_Invoice is Auto Increment
everytime i run the script and hit the button. It will just add. of course the SQL cannot read this as duplicate since the APP2_Invoice.id is always Incrementing everytime you add.

is there any way using SQL command?! or do i have to do it the hard way?!

All helps, Comments, Suggestion or even Snippets ;) is Deeply much Appreciated.


You can insert the records from 1 where the transno is not in 2. Something like this, but am a little rusty:

INSERT INTO app2 (transno, amount, subject) 
SELECT transno, amount, name
    FROM app1
    WHERE transno NOT IN (
        SELECT transno FROM app2

**Check Following Query:

INSERT INTO webapp1.App1_invoice(transno, amount, subject)(SELECT transno, amount, name
    FROM webapp2.App2_invoice
    WHERE transno NOT IN (
        SELECT transno FROM webapp1.App1_invoice

Well thanks for the help guys,in reality the two tables doesn't have the same columns neither same structure (yes they do related but i analyze this out to sort the related columns of the two table) yeah, i think i have the wrong question.. well i'm tryin to figure out by myself. thanks anyways !