Hi Doug,

First, thanks for the idea. Well, We solved the problem using 2 selects.
Actually I was doing what you suggested. I used a "little" select using
limit 0,10 and got the last DATE value. So, with this value I can construct
the WHERE part easily of the second select. it's working fine, but, I just
wanted to optimize it trying to make it with only one select. I tried to use
de LAST_INDEX() function, that catch the last inserted AUTO_INCREMENT, but I
could'nt do it!. I'm trying to make some kind of REGEXP but I'm almost
giving up. Some friend of mine told me that TWO selects aren't recommended,
but in this case I can't see no other way to do this.

If you have any other idea, it will be very helpfull.

Thanks!

Regards,

Felipe


-----Mensagem original-----
De: Doug Durham [mailto:[EMAIL PROTECTED]]
Enviada em: quarta-feira, 4 de dezembro de 2002 01:03
Para: Felipe Moreno - MAILING LISTS
Assunto: Re: RES: SQL Select Idea


Felipe -

Maybe you could...

(1) Put the first result set into a temp table, on which you could execute
subsequent queries, or

(2) Use php to construct an array of the result rows, and then use php's
array-sorting functions, but I'm not sure why you couldn't...

(3) Go back to the db for fresh data with a WHERE clause modification based
on user input.

- Doug


At 07:02 PM 12/3/2002 -0200, you wrote:
>Hi Jim and others that tried to help me!
>Thanks for any kind os answer.
>
>    Well, the SQL command that you suggested don't work for me. Below, I
will
>show What I want and what I get if I use the select command you suggested:
>
>
>1) What I have:
>
>Table: processo_arquivos
>
>_________________________
>|Cod            | Date  |
>-------------------------
>|1              | 12/10 |
>-------------------------
>|2              | 13/10 |
>-------------------------
>|3              | 14/10 |
>-------------------------
>|4              | 15/10 |
>-------------------------
>|5              | 16/10 |
>-------------------------
>
>
>2) What I get is I use the SELECT * FROM processo_arquivos ORDER BY DATE
>DESC LIMIT 0,3 (considering that I only want 3)
>
>_________________________
>|Cod            | Date  |
>-------------------------
>|5              | 16/10 |
>-------------------------
>|4              | 15/10 |
>-------------------------
>|3              | 14/10 |
>-------------------------
>
>3) The problem getting the result like this:
>
>Since I have a link in the header of the tabel that make the ORDER BY work,
>when I select de COD after the result above, I should get:
>
>_________________________
>|Cod            | Date  |
>-------------------------
>|3              | 14/10 |
>-------------------------
>|4              | 15/10 |
>-------------------------
>|5              | 16/10 |
>-------------------------
>
>but instead of the above I get:
>
>_________________________
>|Cod            | Date  |
>-------------------------
>|1              | 12/10 |
>-------------------------
>|2              | 13/10 |
>-------------------------
>|3              | 14/10 |
>-------------------------
>
>So, the problem is when I select a new ORDER BY I make the query in the
>entire Table. What I want is to make the query only in the matched results.
>I have a php page that starts with a default search (the ten dates). So,
>what I really need ia an way to make a select without any "data" from the
>DB. I tried to use de LAST_INDEX() function to do this but I didn't go
>anywhere. Any ideas???
>
>
>Best Regards,
>
>Felipe
>
>
>
>
>
>-----Mensagem original-----
>De: Jim Esten [mailto:[EMAIL PROTECTED]]
>Enviada em: terça-feira, 3 de dezembro de 2002 17:40
>Para: 'Felipe Moreno - MAILING LISTS'; [EMAIL PROTECTED]
>Assunto: RE: SQL Select Idea
>
>
>Something on the order of...
>
>SELECT * FROM processo_arquivos ORDER BY DATE DESC LIMIT 0,10
>
>Seems like that ought to do it..
>
>Jim
>
>Jim Esten
>Chief Techbot
>WebDynamic  http://www.wdynamic.com
>
>-----Original Message-----
>From: Felipe Moreno - MAILING LISTS [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, December 03, 2002 10:39 AM
>To: [EMAIL PROTECTED]
>Subject: SQL Select Idea
>Importance: High
>
>
>Hi List Users,
>
>    I want to know if anyone has any idea on how can I do the SQL command
>below to archive a result.
>    I have one table called processo_arquivos that have a filed called
>DATE and another FIELD called COD (primary key). I want to select the
>last TEN
>(10) dates from the Database, but only the last TEN. How Can I do this?
>Any ideia? I tried the sql bellow o archive this, but I was unable to do
>it. I just want to do this with ONLY one select, not with two.
>
>Thanks for any idea.
>
>Regards,
>
>Felipe
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail
><[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail
<[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to