C# Mysql 查询 Rownum的解决方法
程序员文章站
2024-02-21 21:55:46
sql:
复制代码 代码如下:select @rownum:=@rownum+1 as rownum,a.order_id ,case when a.ordered =1...
sql:
复制代码 代码如下:
select
@rownum:=@rownum+1 as rownum,
a.order_id ,
case when a.ordered =1 then '已分单' 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
sql语句在navicat中查询没有问题,但在程序中各种报错。
尝试过将@改为?,也尝试过传参的方法,但都不成功。
最后,还是在*中找到了解决方案:
allow user variables=true;
问题成功解决。