0

hi so that's my problem :(i'm working in eclipse with java ) i have this table phone(id,mark,reference,OS) and i have 3 seller vend1,vend2,vend3(id,mark,reference,os,price) i want insert all data from vend1 and vend2 and vend3 into the table phone without price so i want to insert the phone if don't exist in the table phone because 2 or 3 seller can have the same phone but i want to insert just one in table phone. hope you can help.

2 Answers2

0

You could use a series on insert-select statements:

INSERT INTO phone
SELECT is, mark, reference, os
FROM   vend1
WHERE  NOT EXISTS (SELECT *
                   FROM   phone
                   WHERE  phone.id = vend1.id)

Similarly, you could create statements for the vend2 and vend3 tables.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Use the merge . It will let you delete rows on the target table based on the where clause. You can check here http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm – JToddler Jan 01 '16 at 20:03
0

You can use MERGE statement. You can accomplish your requirement with merge.

JToddler
  • 790
  • 1
  • 6
  • 16