Reputation: 47
Please Help me. how to update ALL data database1 from database2? QUERY TO UPDATE THIS DATABASE1 i have two database : 1. database1, table product :
================================
| model | pricelow | pricehigh|
================================
| A2345 | 64 | 74 |
| A2350 | 50 | 60 |
database1
=====================================================
model_master | pricelow_master | pricehigh_master |
=====================================================
|A2345 | 70 | 80 |
|A2350 | 60 | 65 |
database2
Upvotes: 0
Views: 80
Reputation: 9583
You need an unique key for update. Here i use id
.
Try this may be helpful to you.
For Update:
UPDATE database1 p, database2 pm SET
p.model = pm.model_master,
p.pricelow = pm.pricelow_master,
p.pricehigh = pm.pricehigh_master,
WHERE p.id = pm.id
For Insert:
INSERT INTO database1 (model, pricelow, pricehigh) SELECT model_master, pricelow_master, pricehigh_master FROM database2
Upvotes: 1