2015-04-07 36 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

不是他正在寻找的答案 –

相关问题