ai didi

sql - “where”或附近的Postgresql语法错误

转载 作者:行者123 更新时间:2023-12-03 08:28:55 24 4
gpt4 key购买 nike

我收到错误

syntax error at or near "where" LINE 5: where zip in (select zipcode from zips where city = 'Sacra



当我尝试运行此代码时。
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');

有人看到容易解决的错误吗?还是我想出了一些垃圾代码?

最佳答案

子句之前的子句之前添加结束关键字

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

关于sql - “where”或附近的Postgresql语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29485371/

24 4 0
文章推荐: archunit - archunit中成员和字段有什么区别
文章推荐: javascript - 由于列中存在空值,对象过滤器不起作用
文章推荐: node.js - promise nodejs + postgresql 中的错误句柄
文章推荐: php - 如何在PHP中获取 sphinx 连接失败错误
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com