【发布时间】:2017-11-13 04:44:58
【问题描述】:
我正在尝试通过为 Postgresql 编写带有 if 条件的查询来在 NamedParameterJdbcTemplate 中使用查询。
我将向查询、store 和 tot_store 传递 2 个参数。我尝试了以下查询,但它不起作用。有什么建议吗?
IF (:store=1)
BEGIN
SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store asc;
END
ELSE IF (:store = 2)
BEGIN
SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store asc;
END
ELSE
BEGIN
SELECT * FROM store_pricing WHERE store = :store and tot_store = :tot_store ORDER BY store desc;
END
错误提示
syntax error at or near "IF"
提前谢谢你
【问题讨论】:
-
你遇到了什么错误?
-
我在上面的问题中添加了错误。
标签: java sql postgresql spring-jdbc