在使用phpmyadmin获取结果
运行以下查询时SET @rownr=0;
SELECT TVGD.video_id,TVM.Video_Title,@rownr:=@rownr+1 AS `Order`,'0' As Min_Pass_Mark
FROM tbl_video_group_details TVGD,tbl_Video_Master TVM WHERE TVGD.video_id=TVM.id AND TVGD.group_id='23'
但是使用mysql_query()函数
运行时,同样会返回语法错误答案 0 :(得分:2)
mysql_query()
不支持多个语句,例如1)SET @rownr=0;
2)您的查询可以重写您的查询,如下所示
SELECT
TVGD.video_id,
TVM.Video_Title,
@rownr := @rownr + 1 AS `Order`,
'0' AS Min_Pass_Mark
FROM
tbl_video_group_details TVGD,
tbl_Video_Master TVM ,
(SELECT @rownr := 0) t
WHERE TVGD.video_id = TVM.id
AND TVGD.group_id = '23'
或者您可以使用支持多个语句的mysqli::multi_query