我有一個查詢:
INSERT INTO rates (name, value, time)
SELECT name, value, time
FROM updated_rates
ON CONFLICT (name) DO UPDATE
SET value = excluded.value, time = excluded.time;
TRUNCATE updated_rates;
如果 updated_rates 不為空,如何更改查詢以執行上述操作
uj5u.com熱心網友回復:
您可以使用exists:
exists (select * from updated_rates)
但如果它是空的,它根本不會插入任何東西。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/433982.html
標籤:sql PostgreSQL where子句 存在
