Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

Update and insert in one query (no replies)

$
0
0
Hi,

I want to update one table and insert to another table in one query, but the insert command cannot see the statement.id from the update. Appreciate clues

update Device, (select id, alertState, lastContact from Device where lastContact < 1511765116 and alertState = 0) as statement set Device.alertState = 1 where Device.id = statement.id; insert Alert (DeviceId, Message) value (statement.id, "Alert");

Thank you.

Kind regards,

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>