0

我通过 jdbc PreparedStatement 触发两个选择查询,
查询由分号(默认分隔符)分隔,
它给了我以下错误

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'select inq.preffered_date as 'dom' , inq.id from assigned_inquiries ai join inqu' 附近使用正确的语法

select inq.preffered_date as .........是第二个查询开始的地方。

编辑-> 查询

select
    ms.next_date_of_meeting as 'dom',
    ms.inquiry_id as 'id'
from
    assigned_inquiries ai,
    meeting_status ms
where
    ai.representative_id = 1
    and (
        ai.status = 'postponed'
        or ai.status = 'remeeting'
    )
    and ai.inquiry_id = ms.inquiry_id
    and ms.next_date_of_meeting between '2012-1-1' and '2012-12-31'
    and ms.created_on = (select max(created_on) from meeting_status where inquiry_id = ms.inquiry_id);

select
    inq.preffered_date as 'dom',
    inq.id
from
    assigned_inquiries ai
    join inquiry inq on ai.inquiry_id = inq.id
where
    ai.representative_id = 1
    and ai.status = 'new'
    and inq.preffered_date between '2012-1-1' and '2012-12-31';

是否可以一次执行两个查询。请帮忙。

4

1 回答 1

3

您可以使用 MySQL 一次执行多个语句。但是,默认情况下禁用此功能。要启用它,请使用属性allowMultiQueries。有关更多信息,请参阅 JDBC 驱动程序的 MySQL 文档:http: //dev.mysql.com/doc/refman/5.5/en/connector-j-reference-configuration-properties.html

于 2012-04-20T13:31:39.353 回答