這裏是我試過的sql查詢。SQL SELECT語句中的算術操作
function getall() {
$connection = new Connection;
$connection->open();
$query = "SELECT position.id,position.name_position,position.g_position,position.cs,position.totalbefore,
COUNT(position2.staff_id) AS cnt_staff,
totalbefore-cnt_staff AS totalafter
FROM position
INNER JOIN position2 ON position.id = position2.id_position2
WHERE position.status_data= '1'
GROUP BY position2.id_position2";
$result = mysql_query($query);
return $result;
}
此代碼返回語法錯誤。 IDK放在哪裏算術運算(totalbefore-cnt_staff AS totalafter)在statement.can有人幫我請
檢查您的列名稱,如「totalbefore-cnt_staff」。這可能是totalbefore_cnt_staff –