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,
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,