不是啊,Level字段一定要,比如说有这样几个值:
0, 1, 2, 1, 0, 1
就必须要排列成:
0, 1, 2, 1, 0, 1
如果不管Level字段的话就会变成:
0, 1, 1, 2, 0, 1
0, 1, 2, 1, 0, 1
就必须要排列成:
0, 1, 2, 1, 0, 1
如果不管Level字段的话就会变成:
0, 1, 1, 2, 0, 1
解决方案 »
- 求个sql语句
- 关于 mysql 中的 desc table_name
- select distinct的sql语句如何优化
- 有关定时备份的问题,谢谢大家
- solidDB for mysql怎么安装?
- windows下的mysql报“table is full”的解决方案
- 选择 PostgreSQL 的理由, 请你加贴!
- 新手问题:怎样使用MySql?
- 求助!!我的MYSQL缺少程序!
- 数据库集群节点问题,老是连不上解决不了:Unable to connect with connect string: nodeid=0
- 安装mysql后的root密码设置问题
- 在servlet中用mysql乱码问题
0,1,1,2,1,2,3,0,1
我要求得到的结果是
0,1,2,3,1,2,1,0,1
select * from testtable order by Parent desc,Level asc,ID desc;
我比如Level有下列的值:
0,1,1,2,2,3,3,4,5,1,2
如果Level按照你的方法排列就是下面这样的结果:
0,1,1,1,2,2,2,3,3,4,5
但我要的结果是:
0,1,2,3,4,1,2,3,1,2
然后在第二次查询,第一个表,并与那个临时表数据输出
insert into temp select * from testtable order by ID desc,Parent desc;
将testtable -> temp中
insert into temp2 select * from testtable Level 分组排序(我不知用什么可以做到,我没用过)
将testtable -> temp2中
select t.*,t2.* from temp t,temp2 t2
就可以。
你也可以存到数组中,然后输出。
上面的SQL语句,不一定能运行。这是PL/SQL的。mysql好象没有insert into table select * from table;