r/SQL•
Breezing

Looking for a simple explanation of a strange behavior...

PostgreSQL

Hi!

Currently working my way through PostgreSQL, but i'm having some sort of cognitive breakdown on the Update Multiple one.

The valid code that works is

update cd.facilities
  set
     membercost = 6,
     guestcost = 30
  where facid in (0,1);  

My first try was coded like thus:

UPDATE cd.facilities
	SET guestcost = 30,
		membercost = 6
	WHERE name LIKE 'TEN%'
	;

I recognize that it didn't work appropriatley because of the badly cased TEN%, and works when it is Ten%.

However, what I'm wondering is why do the values for guestcost and membercost decrease by 1 and 5 on the two Tennis entries with the wrong code?

Sorry if it's something super simple i'm missing.

Posted Nov 29, 2019, 2:36 PM UTC

12
secretWolfMan•

Because the values used to be 31 and 11?

There is nothing there that would repeatedly decrement your fields.

1
BreezingOP•

Strange. Glad to know I didn't fuck it up too bad. Thanks!

1