【发布时间】:2018-12-21 00:13:55
【问题描述】:
是否可以在一个 sql 查询中更新多条记录?
因此,将 ID 为 A 和 ip 1.1.1.1 的所有打印机的状态更新为工作(真),而其他所有打印机的状态都更新为不工作(假)
所以基本上将这两个查询组合成一个查询:
update printers set status = true ,row_update_date =sysdate where printer id = 'A' and printer ip = '1.1.1.1'
update printers set status = false ,row_update_date =sysdate where printer id = 'A' and printer ip != '1.1.1.1'
表结构:
printers table:
printer ID,printer ip, status,row_update_date
A ,1.1.1.1 ,
A ,1.1.1.2 ,
A ,1.1.1.3 ,
A ,1.1.1.4 ,
B ,1.1.2.1 ,
B ,1.1.2.2 ,
更新
我忘了 row_update_date !
【问题讨论】: