找不到预期的关键字

时间:2018-05-15 01:59:05

标签: java mysql sql jsp servlets

如何修复未找到预期错误的关键字!请任何人帮忙 感谢

未找到FROM关键字"执行查询时

String query = "select  bc.institution_code,bc.branch_code,tmp.order_channel,tmp.order_root_div,"
        + "count(ls.session_id) as tenlogincount from branch bc,login_session ls,(select    a.session_id,a.branch_id,"
        + "b.order_channel,c.order_root_div from(select session_id,property_value as branch_id"
        + "from login_session_property where property_name = 'branchID') a,(select session_id,"
        + "property_value as order_channel from login_session_property where property_name = 'orderChannel') b,"
        + "(select  session_id,property_value as order_root_div from login_session_property"
        + "where property_name = 'orderRootDiv') c where    a.session_id = b.session_id"
        + "and  b.session_id = c.session_id) tmp where  to_char(ls.creation_date, 'YYYY-MM-DD') = ?"
        + "and  ls.type_id in  (select type_id from login_type where type_name like '%customer_login_type%')"
        + "and  ls.session_id = tmp.session_id and  bc.branch_id = tmp.branch_id"
        + "and  ((to_char(ls.creation_date,'HH24MI') <= ? and to_char(ls.last_update,'HH24MI') >= ?"
        + "and  ls.validity <> 0) or    (to_char(ls.creation_date,'HH24MI') <= ?"
        + "and  to_char(ls.expiration_date,'HH24MI') >= ? and   ls.validity = 0)) group by bc.institution_code,"
        + "bc.branch_code,tmp.order_channel,tmp.order_root_div";

1 个答案:

答案 0 :(得分:0)

连接字符串时,需要用空格分隔单词。

例如,在第3行as branch_id的结尾与第4行from login_session_property的开头之间。这将成为as branch_idfrom login_session_property。看到错误?这没有意义。

只需确保在每行的末尾添加一个空格,以确保在构建整个字符串时分隔单词。第3行的结尾应该看起来像as branch_id&lt; - 这里最后一个空格。

你有几行有同样的错误。