2026-10-23 12:44 UTC
Can you spot why this same query behaves differently on Microsoft SQL Server and on PostgreSQL?
```
UPDATE osupdate
SET devices_count = 0
FROM osupdate AS ou
WHERE ou.devices_count > 0
AND NOT EXISTS (
SELECT device_id
FROM deviceosupdate WHERE osupdate_id=ou.id)
```
#database #postgres #sqlserver #programming
Replies (2)
-
@truls46@mastodon.social 2026-10-23 12:47
@petarov@social.tchncs.de Does device_id exist as a column in the table osupdate? Try to also use an alias for deviceosupdate in the subquery and qualify all columns with the correct alias.
-
@caravantraveller@social.cologne 2026-10-23 14:24
@petarov@social.tchncs.de Always provide the tables, like 'create table ...' and some data like 'insert into ...' That makes it far easier to investigate.