Posts: 2
Name: ahmed mohammed helmi
|
hello guys
i have tried to run this on PHP
PHP Code:
public function topicsPerdept($q) {
$sql = "set @num := 0, @n2 := 0;
SELECT `department_id`, `name`, COUNT(`department_id`) AS 'number_of_thesis',
@num := 1 AS 'y',
@n2 := @n2 + 3 AS 'x'
FROM `thesis` INNER JOIN `department`
ON thesis.department_id= department.ID
WHERE thesis.title LIKE '%$q%' OR thesis.keyword LIKE '%$q%'
GROUP BY department_id";
but it dose not work idk why  & it gives me this
Reason: Server error MySQL Error - 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 'SELECT `department_id`, `name`, COUNT(`department_id`) AS 'number_of_thesis', ' at line 2
|