Home > Database > Mysql Tutorial > C# Mysql 查询 Rownum的解决方法_MySQL

C# Mysql 查询 Rownum的解决方法_MySQL

WBOY
Release: 2016-06-01 13:23:59
Original
1029 people have browsed it

bitsCN.com

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中查询没有问题,但在程序中各种报错。

尝试过将@改为?,也尝试过传参的方法,但都不成功。

最后,还是在StackOverflow中找到了解决方案:

Allow User Variables=True;

问题成功解决。

bitsCN.com
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template