【问题标题】:Multiple columns in, IN clause Apache DerbyIN 子句中的多个列 Apache Derby
【发布时间】:2018-06-18 22:20:37
【问题描述】:

我有以下 SQL 查询:

SELECT
    ORDER_ID,
    ORDER_CODE
FROM
    ORDERS
WHERE
    (ORDER_ID,SEQUENCE) in ((?,?))

PreparedStatement statement = connection.prepareStatement(sql)

上述代码行在 Oracle 中使用上述查询成功生成了一个 PreparedStatement 对象,但在 Apache Derby 中,它抛出了以下异常:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "," at line 8, column 14.

谁能解释一下如何在 DERBY 的 IN 子句中查询多个列。

参考帖:
http://apache-database.10148.n7.nabble.com/Using-IN-clause-with-multiple-columns-td98558.html

谢谢!

【问题讨论】:

  • 请分享真实的查询!
  • 用真实的查询更新了帖子。
  • 现在可以给我们看看你的代码吗?
  • 看起来 Derby 不支持该语法。
  • 为什么不:select order_id,order_code from orders where order_id = ? and sequence = ?

标签: java prepared-statement multiple-columns derby sql-in


【解决方案1】:

结论:Derby 不支持prepared statement 的多个IN 子句。 (?,?) -- 这种语法会引发错误。

迁移到 H2 数据库进行测试会更好,因为它可以在那里进行并且更强大。

【讨论】:

    猜你喜欢
    • 2017-11-26
    • 2012-10-13
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 2016-10-23
    • 2019-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多