【发布时间】:2014-03-26 18:59:59
【问题描述】:
我一直在努力
exception 'PDOException' with message 'SQLSTATE[42000]:
Syntax error or access violation: 1064
You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near
'(questionid, 'sfname' , 'slname' , 'school' , 'grade' , 'addr' , 'city' , 'state' at line 1'
来自此声明:
$stmt = $db->prepare('SELECT * FROM event_responses WHERE eventid= :eventid ORDER BY userid DESC, field (questionid, \''.implode("' , '", $columns1).'\')');
我在里面附和了这个声明,我觉得很好:
SELECT *
FROM event_responses
WHERE eventid= :eventid
ORDER BY userid DESC,
field (questionid, 'sfname' , 'slname' , 'school' , 'grade' , 'addr' , 'city' , 'state' , 'zip' , 'semail' , 'sphone' , 'pfname' , 'plname' , 'pemail' , 'pphone' , 'noattend' , 'regid' , 'submitDate' , 'attended' , 'regmethod')
为什么会这样?
【问题讨论】:
标签: php mysql sql pdo sql-order-by