Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
84 views
in Technique[技术] by (71.8m points)

php - ON DUPLICATE KEY UPDATE for multiple rows, not columns

I need a query that will insert multiple records into a table but if exists, update the column labeled status for each row.

ON DUPLICATE KEY UPDATE is the solution to this problem but what if I have more than one row? ON DUPLICATE KEY UPDATE is only updating 1 of 2 rows.

For example, I want to insert table A into table B which works fine but if there's an update to the status column on table A, i want to update the status column for each row on table B.

Table A

tableA_id tableA_company_entity. tableA_product tableA_ordern tableA_status
1 Apple_44 Phone 456 Pending
2 Apple_44 Watch 689 Pending
question from:https://stackoverflow.com/questions/66051594/on-duplicate-key-update-for-multiple-rows-not-columns

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...