C Mysql queries Rownum's solution
- 2020-05-15 02:23:58
- OfStack
Sql:
SELECT
@rownum:=@rownum+1 AS rownum,
a.order_id ,
case when a.Ordered =1 then ' Has been single ' end as Ordered,
a.printed ,
a.order_sn ,
a.user_id ,
b.user_name ,
a.consignee ,
a.tel ,
a.mobile ,
a.address ,
a.pay_name ,
a.goods_amount ,
a.shipping_fee ,
FROM_UNIXTIME(a.add_time+8*3600) ,
a.postscript ,
a.best_time
FROM (SELECT @rownum:=0) r,xj_order_info a INNER JOIN xj_users b on a.user_id =b.user_id
where (order_status ='1') and (FROM_UNIXTIME(a.add_time) between '{0}' and '{1}')
ORDER BY rownum asc
The sql statement has no problem querying in Navicat, but various errors are reported in the program.
Tried changing @ to? , also tried to pass the method, but they were not successful.
Finally, a solution was found in StackOverflow:
Allow User Variables = True;
The problem was successfully solved.