我想在同一代码中运行2个查询,但是我不知道该怎么做。这两个查询如下:
UPDATE usercomp
SET shiftstart = shifts.shiftstarttime,
shiftfinish = shifts.shiftfinishtime
FROM shifts
WHERE usercomp.shiftid = shifts.id
SET break1start = breaks.timestarted,
break1finish = breaks.timefinished,
break1duration = breaks.duration
FROM breaks
WHERE usercomp.break1id = breaks.id;
我遇到以下错误:
ERROR: syntax error at or near "SET"
LINE 6: SET break1start = breaks.timestarted,
任何人都可以帮忙吗?
答案 0 :(得分:0)
您需要编写两个UPDATE
语句
UPDATE usercomp
SET shiftstart = shifts.shiftstarttime,
shiftfinish = shifts.shiftfinishtime
FROM shifts
WHERE usercomp.shiftid = shifts.id;
UPDATE usercomp
SET break1start = breaks.timestarted,
break1finish = breaks.timefinished,
break1duration = breaks.duration
FROM breaks
WHERE usercomp.break1id = breaks.id;