Reputation: 25
I am getting the error
syntax error at or near "where" LINE 5: where zip in (select zipcode from zips where city = 'Sacra
when I try to run this code.
update listings
set price = CASE WHEN (listings.price IS NOT NULL) THEN (price *
(((100+(select price_change from zips where zips.zipcode=listings.zip))/100)))
where zip in (select zipcode from zips where city = 'Sacramento');
Does anybody see any easy to fix errors? or did I come up with some garbage code?
Upvotes: 0
Views: 5318
Reputation: 21945
Add an end keyword just before where clause
update listings
set price = CASE WHEN (listings.price IS NOT NULL) THEN (price *
(((100+(select price_change from zips where zips.zipcode=listings.zip))/100))) END
where zip in (select zipcode from zips where city = 'Sacramento');
As per @a_horse_with_no_name's Comment
update listings
set price = (price * (((100+(select price_change from zips where zips.zipcode=listings.zip))/100)))
where zip in (select zipcode from zips where city = 'Sacramento') and listings.price IS NOT NULL
Upvotes: 0
Reputation: 278
update listings
set price = CASE WHEN (listings.price IS NOT NULL) THEN (price *
(((100+(select price_change from zips where zips.zipcode=listings.zip))/100)))
where zip in (select zipcode from zips where city = 'Sacramento')
remove ; try again
Upvotes: 0