[PHP-users 34549] Re: MySQLのデータ追加の順番

もじもじ mojimoji528 @ yahoo.co.jp
2009年 4月 22日 (水) 18:43:19 JST


もじもじです。

drop table if exists a;
create table a ( a int, t timestamp );
insert into a set a = 3;
insert into a set a = 2;
insert into a set a = 1;
select a from a order by t;

うまくいかないですね。

drop table if exists a;
create table a ( id int auto_increment, a int, primary key( id ) );
insert into a set a = 3;
insert into a set a = 2;
insert into a set a = 1;
select a from a order by id;

で、

drop table if exists a;
create table a ( id int auto_increment, a int, primary key( id ) );
insert into a ( a ) values ( 3 ),( 2 ),( 1 ),( 5 ),( 6 ),( 7 );
select a from a order by id limit 3, 2;

Wed, 22 Apr 2009 18:16:50 +0900 に、
朧月 <oboro @ ebetsu.arrow.jp> さんは書きました:

> お世話になってます、朧月です。
> 
> qujila wrote (2009/04/22 18:08):
> 
> > insertされた行を後からselectで取り出す時に、orderで順番を決めるんじゃな
> > いでしょうか?
> 
> それも考えたのですが、今書いているコードは10件ごとにデータを一覧表示し
> て、11件目以降は2ページ目、というようなものです。
> 
> そうなると、時系列で並んでいないと微妙に都合が悪い感じなのです。
> 
> 
> -- 
> 朧月
> mailto:oboro @ ebetsu.arrow.jp
> _______________________________________________
> PHP-users mailing list  PHP-users @ php.gr.jp
> http://ml.php.gr.jp/mailman/listinfo/php-users
> PHP初心者のためのページ - 質問する前にはこちらをお読みください
> http://oldwww.php.gr.jp/php/novice.php3

-- 
もじもじ <mojimoji528 @ yahoo.co.jp>



PHP-users メーリングリストの案内