Here is my query woking absolutely fine when entered directly:
SET @new_sno=0;
SELECT(@new_sno:=@new_sno+1) AS sno_new,Products,Price,
case sno WHEN 1 THEN 1 WHEN 2 THEN 2 WHEN 3 THEN 3 WHEN 4 THEN 4
WHEN 12 THEN 5
ELSE 6
END AS orderpriority
FROM rates ORDER BY orderpriority,sno;
but when I use it in php like
$result = mysqli_query($con,"SET @new_sno=0;
SELECT(@new_sno:=@new_sno+1) AS sno_new,Products,Price,
case sno WHEN 1 THEN 1 WHEN 2 THEN 2 WHEN 3 THEN 3 WHEN 4 THEN 4
WHEN 12 THEN 5
ELSE 6
END AS orderpriority
FROM rates ORDER BY orderpriority,sno");
The above statement is returning false What can be the solution?
queriesyou need to usemysqli_free_result($result)between them