动态报表排序问题
本帖最后由 jiangj 于 2015-12-24 17:24 编辑动态报表排序问题:
sql中已经写了order by ,但是页面出来的数据不是按这个字段排序的,
我写的sql是:
select a.member_name,c.real_name,b.phone,a.recharge_id,a.is_effect,a.money,a.time ,a.typefrom tjtyy_member_recharge a,tjtyy_member b , tjtyy_member_real_info c
where a.is_effect = 1 and a.member_id = b.id and a.member_id = c.member_id order by a.time desc
跟踪代码到封装sql,得到的sql是:
select * from ( SELECT t.* FROM ( select a.member_name,c.real_name,b.phone,a.recharge_id,a.is_effect,a.money,a.time ,a.typefrom tjtyy_member_recharge a,tjtyy_member b , tjtyy_member_real_info c
where a.is_effect = 1 and a.member_id = b.id and a.member_id = c.member_id order by a.time desc ) t ) sel_tab00 limit 0,20
在数据库中执行封装得到的sql就不是按时间倒序排的,请问这个怎么解决?
补充下:mysql数据库 select * from (
SELECT
a.member_name,
c.real_name,
b.phone,
a.recharge_id,
a.is_effect,
a.money,
a.time,
a.type
FROM
tjtyy_member_recharge a,
tjtyy_member b,
tjtyy_member_real_info c
WHERE
a.is_effect = 1
AND a.member_id = b.id
AND a.member_id = c.member_id
) t
ORDER BY
t.time DESC hero_xu 发表于 2015-12-25 14:20 static/image/common/back.gif
select * from (
SELECT
a.member_name,
select * from (
SELECT
a.member_name,
c.real_name,
b.phone,
a.recharge_id,
a.is_effect,
a.money,
a.time,
a.type
FROM
tjtyy_member_recharge a,
tjtyy_member b,
tjtyy_member_real_info c
WHERE
a.is_effect = 1
AND a.member_id = b.id
AND a.member_id = c.member_id
) t
ORDER BY
UNIX_TIMESTAMP(t.time) DESC 代码中写死了,页面中需要排序的字段得设置别名为time,这样写我知道可以,但是不科学啊!
页:
[1]