Sql 错误 "Syntax error or access violation: 1064"

Sql error "Syntax error or access violation: 1064"

获取(语法错误或访问冲突 1064)不知道是什么问题。为什么我收到这个错误?我认为 DATE

的语法有问题

这是错误的屏幕:

我的代码:

$sql = "SELECT ds.id
FROM documents ds
INNER JOIN institutions_if ib on ds.to_inst_id = ib.id
INNER JOIN documents_log dl on ds.id = dl.doc_id
WHERE
  ds.to_inst_id in :insts
  AND DATE(FROM_UNIXTIME(dl.timestamp)) = '2014-12-31'   //   <======== ERROR HERE!!!!!
  AND ds.status in ('sent','received','accepted','archived')
  AND ds.template_id = :template1
  AND NOT EXISTS (
    SELECT id FROM documents dr
        WHERE
            dr.reply_to = ds.id
            and dr.template_id = :template2
            and dr.status in ('sent','received','accepted','archived')
            and dr.to_inst_id in :insts
        );";

  $result = db_query($sql, array(
    ':insts' => institution_children_plan('[237, 279, 373]'),
    ':template1' => DocumentTemplate::get_template_by_handler('disp_suspend_operat_cont'),
    ':template2' => DocumentTemplate::get_template_by_handler('comun_anul_disp_susp_oper')
  ));

您错过了第一个 IN 内容周围的 ()

WHERE   ds.to_inst_id in (:insts)

所以你在下一个 AND

上出错了