|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I have to extract elements from a table ordered in a special way. For example select id,name from table_name order by age*weight; It seems to be not efficient to order rows each time when I extract information from the table. Is that possible to keep table-rows in specific order? In other words I want to order rows of the table once (and force the table to remember this order), so the mysql-server does not need to order the rows each time when I "select" rows from the table (because the rows in the table will be already in the correct ordered). And the second question. What should I do if i need NOT all rows of the table but only top 10? Thank you. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Kurda Yon wrote:
> Hi, > > I have to extract elements from a table ordered in a special way. For > example > select id,name from table_name order by age*weight; > > It seems to be not efficient to order rows each time when I extract > information from the table. Is that possible to keep table-rows in > specific order? In other words I want to order rows of the table once > (and force the table to remember this order), so the mysql-server does > not need to order the rows each time when I "select" rows from the > table (because the rows in the table will be already in the correct > ordered). > > And the second question. What should I do if i need NOT all rows of > the table but only top 10? > > Thank you. Create an index holding your chosen value |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
>
> Create an index holding your chosen value Is that possible to extract only top 10 elements? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"Kurda Yon" <kurdayon@yahoo.com> schreef in bericht news:cf45bcd7-fa0d-4cfb-9f3b-a3e21b9fa1de@k39g2000hsf.googlegroups.com... > > >> Create an index holding your chosen value > > Is that possible to extract only top 10 elements? start reading: http://dev.mysql.com/doc/refman/5.0/en/select.html especially the part about LIMIT |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
>
> Create an index holding your chosen value Do you mean "primary key"? The problem is that the column declared with the primary key should hold _unique_ values. In my case, some rows can have the same value of the argument which I want to use for the ordering. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 5 Feb, 00:46, Kurda Yon <kurda...@yahoo.com> wrote:
> > Create an index holding your chosen value > > Do you mean "primary key"? The problem is that the column declared > with the primary key should hold _unique_ values. In my case, some > rows can have the same value of the argument which I want to use for > the ordering. No, I mean create an index. An index can be a unique or a non-unique index. |
|
![]() |
| Outils de la discussion | |
|
|