我正在运行MYSQL 5.5版,我收到以下错误。我已尝试将LIMIT 1
添加到最后,删除ORDER BY DESC
指定按DATE(submit_date)
排序...但仍然收到相同的错误。
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的“ORDER BY DESC”附近使用正确的语法
function getApplicationStatus($userId) {
$SQLString = "SELECT status, DATE(submit_date) FROM ". $GLOBALS['TABLES']['APPLICATION'] ." WHERE fk_userid = $userId ORDER BY DESC";
$results = mysqli_query($GLOBALS['DB']['CONNECT'], $SQLString) or die("Error: ".mysqli_error($GLOBALS['DB']['CONNECT']));
$data = mysqli_fetch_array($results);
return $data['status'];
}
答案 0 :(得分:3)
您在订单中缺少一个字段:ORDER BY DESC
添加字段:ORDER BY someField DESC
或删除ORDER BY DESC
文字。
答案 1 :(得分:0)
您应该指明column_name。
SQL ORDER BY语法:
SELECT column_name, column_name
FROM table_name
ORDER BY column_name ASC|DESC, column_name ASC|DESC;
答案 2 :(得分:0)
试试这个。 $ SQLString =" SELECT状态,DATE(submit_date)FROM"。 $ GLOBALS [' TABLES'] [' APPLICATION']。"在哪里fk_userid = $ userId ORDER BY' submit_date' DESC&#34 ;;