Zouhaier Mhamdi Geotentic Zouhaier Mhamdi Geotentic - 7 months ago 18
SQL Question

Newly added Column can't be updated even in pgadmin

When i do:

select * from realtimes where realtime_id = 538189069


i can see my columns is_limitation_zone_overspeed and zone_speed_limit

enter image description here

but when I update it

update realtimes
set is_limitation_zone_overspeed = true and zone_speed_limit = 90
where realtime_id = 538189069


these field are not affected despite pgadmin
return Query returned successfully: 1 row affected, 181 ms execution time

any idea ? thanks

Answer

is_limitation_zone_overspeed = true and zone_speed_limit = 90 only updates a single column and that is: is_limitation_zone_overspeed.

And that column is updated with the result of the boolean expression:

true and zone_speed_limit = 90

To update two columns you need a comma:

update realtimes 
   set is_limitation_zone_overspeed = true, --<< here!
       zone_speed_limit = 90 
where realtime_id = 538189069 

You might want to go through the SQL tutorial in the manual: