Can I use multiple statements in a JDBC prepared query?

前端 未结 2 342
暖寄归人
暖寄归人 2021-01-17 17:23

I\'d like to execute something like this on my MySQL server:

SET @id=(SELECT id FROM lookupTable WHERE field=?);
(SELECT * FROM table2 WHERE id=@id)
UNION
(S         


        
相关标签:
2条回答
  • 2021-01-17 17:43

    JDBC has never supported parsing delimited queries. Each invocation is one trip to the database. Perhaps you can achieve what you meant to doing PreparedStatement.addBatch() for each separate query, then executing and retrieving the two resultsets ?

    0 讨论(0)
  • Just running this as two separate queries (within one connection) should give you same results.

    0 讨论(0)
提交回复
热议问题