create table a (pkid int,name varchar(12),xsl int,hpl int);insert into a values(1,'1',3,4);
insert into a values(2,'2',2,2);
insert into a values(3,'3',1,8);select * from a;
select a.name,b.name from (select * from a order by xsl) a, (select * from a order by hpl) b ;
-
这样取数是重复无效的,我需要为 a b 两个表缔造一个rowid之类的列。然后让a.rowid = b.rowid就可以过滤了。请大家支招!最后需要结果
序号;以xsl排序的name;以hpl排序的name
1 3 8
2 2 4
3 1 2
一共就3条数据 用不着分页。
mysql环境。
就算是有某种分页技术 你能取出来也ok。我的想法就是缔造rowid之类的一个列、大虾有经验的跟我说下
insert into a values(2,'2',2,2);
insert into a values(3,'3',1,8);select * from a;
select a.name,b.name from (select * from a order by xsl) a, (select * from a order by hpl) b ;
-
这样取数是重复无效的,我需要为 a b 两个表缔造一个rowid之类的列。然后让a.rowid = b.rowid就可以过滤了。请大家支招!最后需要结果
序号;以xsl排序的name;以hpl排序的name
1 3 8
2 2 4
3 1 2
一共就3条数据 用不着分页。
mysql环境。
就算是有某种分页技术 你能取出来也ok。我的想法就是缔造rowid之类的一个列、大虾有经验的跟我说下
MySQL中的ROWNUM的实现
+------+------+------+------+
| pkid | name | xsl | hpl |
+------+------+------+------+
| 1 | 1 | 3 | 4 |
| 2 | 2 | 2 | 2 |
| 3 | 3 | 1 | 8 |
+------+------+------+------+
3 rows in set (0.00 sec)mysql> select t11.sno,t11.xsl,t21.hpl
-> from (
-> select t1.xsl,count(*) as sno
-> from a t1 ,a t2
-> where t1.xsl>=t2.xsl
-> group by t1.xsl) t11,
-> (
-> select t1.hpl,count(*) as sno
-> from a t1 ,a t2
-> where t1.hpl>=t2.hpl
-> group by t1.hpl) t21
-> where t11.sno=t21.sno;
+-----+------+------+
| sno | xsl | hpl |
+-----+------+------+
| 1 | 1 | 2 |
| 2 | 2 | 4 |
| 3 | 3 | 8 |
+-----+------+------+
3 rows in set (0.00 sec)mysql>
明白了,大哥接分!Thank 油!
1 3 3
2 2 1
3 1 2 呵呵。没关系了。不过这是个需求,要更正下,万一别人看了都不明白的!
“排 序 是 排 的 name!”