I've got a query:
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;
How to change the query so that it does the actions above if updated_rates is not empty
CodePudding user response:
You can use exists
:
exists (select * from updated_rates)
But if it's empty it will simply not insert anything.