here is the sql query that i've tried.
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;
}
This code return syntax error. Idk where to put the Arithmetic operation (totalbefore-cnt_staff AS totalafter) in the statement.can anyone help me pls