2015-04-07 45 views
0

我收到錯誤PostgreSQL的語法錯誤達到或接近「其中」

語法錯誤達到或接近「其中」 5號線:其中拉鍊在(選擇拉鍊郵政編碼 其中城市=「薩克拉

,當我嘗試運行這段代碼。

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'); 

是否有人看到任何容易修復錯誤?還是我拿出一些垃圾代碼?

+0

你並不需要的情況下,你有沒有'其他「部分。只需在您的where子句中添加「price is not null」,您就可以擺脫整個「CASE」並使更新更加高效。 –

+0

只是看到更新的答案@a_horse_with_no_name建議被添加:) –

回答

0

只是其中條款

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'); 

按@ a_horse_with_no_name的評論之前添加結束關鍵字

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 
0
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') 

刪除;請再試一次

+0

不是他正在尋找的答案 –

相關問題