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.
Asked
Active
Viewed 77 times
0
-
1Please format your question according to posting guidelines. – minatverma Jan 01 '16 at 19:09
-
1What db are you using ? – JToddler Jan 01 '16 at 19:28
2 Answers
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