php - Sql error "Syntax error or access violation: 1064"
问题描述
getting (syntax error or access violation 1064) dont know what is the problem. why i am getting this error? I think problen in my syntax with DATE
here is the screen with error:
My code:
$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')
));
解决方案
You missed the () around the first IN content
WHERE ds.to_inst_id in (:insts)
so you have an error on the next AND
推荐阅读
- javascript - 如何获得所有票价的总和
- android-studio - 如何在whatsapp上从firebase发送音频文件
- powershell - 使用 Invoke power shell 将 Powershell 脚本的输出返回到 UIPath
- python - 根据 Pandas 中的特定条件将值从一列复制到同一行中的其他列
- firebase - 从 Firebase 存储中检索图像到 vue 应用程序
- postgresql - Postgres 8.3 使用查询查询完整的函数定义
- ruby - 如何在`for`循环中退出`if`语句
- bash - 如何在for循环中将两个变量传递给文件夹名称
- mysql - Vapor MySQL 时间戳默认值
- swift - 无法在 Ubuntu 18.04 上使用 Swift