我有一个查询它会更新表格中的整个票证。 我希望它只更新其值需要更新的票证而不更新所有行。 例如 如果slabreachdays已经是10,则新值也是10,它不应该更新。 这是我的更新查询。
update ticket
set TICKET.slabreachdays =
FLOOR(((DAYS(TICKET.creationdate) - DAYS(current timestamp)+10)
* 86400 + (MIDNIGHT_SECONDS(TICKET.creationdate) -
MIDNIGHT_SECONDS(current timestamp)))/86400.0)
where TICKET.VENDOR like 'ABC'
and TICKET.STATUS NOT IN('CANCELLED','CLOSED')
这是我的选择查询,它只选择需要更新的票证。这是我需要转换为更新查询的查询
select * from (
select ticketid,slabreachdays,
FLOOR(((DAYS(TICKET.creationdate) - DAYS(current timestamp)+10) * 86400 + (MIDNIGHT_SECONDS(TICKET.creationdate) - MIDNIGHT_SECONDS(current timestamp)))/86400.0)
as newValue
from ticket
where TICKET.MLOUTSOURCEVENDOR like 'ABC' and TICKET.STATUS NOT IN('CANCELLED','CLOSED'))
where SLABREACHDAYS != newValue
答案 0 :(得分:0)
试试吧
哪里......和slabeachdays<>过敏计算表达
答案 1 :(得分:0)
试试这个
update ticket
set TICKET.slabreachdays =
FLOOR(((DAYS(TICKET.creationdate) - DAYS(current timestamp)+10)
* 86400 + (MIDNIGHT_SECONDS(TICKET.creationdate) -
MIDNIGHT_SECONDS(current timestamp)))/86400.0)
where TICKET.VENDOR like 'ABC'
and TICKET.STATUS NOT IN('CANCELLED','CLOSED') and
TICKET.slabreachdays <>
(FLOOR(((DAYS(TICKET.creationdate) - DAYS(current timestamp)+10)
* 86400 + (MIDNIGHT_SECONDS(TICKET.creationdate) -
MIDNIGHT_SECONDS(current timestamp)))/86400.0))