RES: SQL Select Idea [ORDER BY]

2002-12-06 Thread Felipe Moreno - MAILING LISTS
Hi Michael,

  Using two select's we already solved the problem. The challenge is to make
the same thing using just one select. I need to know if is there an way to
get the last date or the 10th index to make the WHERE part. Like the
LAST_INDEX() function, that gets the last AUTO_INCREMENT...but I just saw
apllacation using the update command. Well, any new ideas?

Best Regards,

Felipe

-Mensagem original-
De: Michael T. Babcock [mailto:[EMAIL PROTECTED]]
Enviada em: quinta-feira, 5 de dezembro de 2002 21:03
Para: [EMAIL PROTECTED]
Assunto: Re: SQL Select Idea [ORDER BY]


On Thu, Dec 05, 2002 at 08:54:29PM -0200, Felipe Moreno - MAILING LISTS
wrote:

 Well, could you explain the behave of ORDER BY DATE,COD?

Just try it (it will order by date, then cod).

What I think you want is (as I originally said, but briefly):

create temporary table top10 select * from ... limit 10;
select * from top10 order by cod;
...

SQL
--
Michael T. Babcock
CTO, FibreSpeed Ltd. (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/

-
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




RES: RES: RES: SQL Select Idea

2002-12-05 Thread Felipe Moreno - MAILING LISTS
Hi Michael,

   The ten last dates appear as a default result of a Archives page. When I
enter for the first time in the page, it give me the last ten Files that was
uploaded. In the same page, I can ORDER BY the ten last dates results by
COD, DATE, NAME or FILE. So, when I click in some os then, I need to ORDER
the TEN DATES, not the entire table and give ten results, did you get it?

Any idea?

Regards,

Felipe


-Mensagem original-
De: Michael T. Babcock [mailto:[EMAIL PROTECTED]]
Enviada em: quarta-feira, 4 de dezembro de 2002 17:33
Para: [EMAIL PROTECTED]
Assunto: Re: RES: RES: SQL Select Idea


On Wed, Dec 04, 2002 at 08:55:51AM -0200, Felipe Moreno - MAILING LISTS
wrote:
Well, the SQL Query you requested is exatcly the one I'm asking! :-)

No; I want to know what you intended for those 10 dates to do.  The LIMIT
query
worked, as posted by someone else, which you quoted.  What do you then
intend
to do with that data?

  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:

 [ you didn't give the EXACT SQL QUERY that you're typing in; please give
 it ]

Again, you didn't quote the when I select the COD after ... -- what is
that
query?  And how do you expect it to behave.

 I'm assuming that you're forgetting a step, or misunderstanding a step
 involved.  Are you doing anything with that data you're selecting, or just
 selecting it and leaving it?  You might be wanting to select it into a new
 table or something; look up INSERT INTO ... SELECT FROM 

This still applies.
--
Michael T. Babcock
CTO, FibreSpeed Ltd. (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/

-
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




RES: SQL Select Idea [ORDER BY]

2002-12-05 Thread Felipe Moreno - MAILING LISTS

Well, could you explain the behave of ORDER BY DATE,COD?

I will show you bellow what I want, graphically:

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 if 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:

PS: When I select the COD (order by COD) it sends the ORDER BY value to the
same select above.

_
|Cod (link) | 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???




-Mensagem original-
De: Michael T. Babcock [mailto:[EMAIL PROTECTED]]
Enviada em: quinta-feira, 5 de dezembro de 2002 16:02
Para: [EMAIL PROTECTED]
Assunto: Re: SQL Select Idea [ORDER BY]


On Thu, Dec 05, 2002 at 09:41:24AM -0200, Felipe Moreno - MAILING LISTS
wrote:
The ten last dates appear as a default result of a Archives page. When
I
 enter for the first time in the page, it give me the last ten Files that
was
 uploaded. In the same page, I can ORDER BY the ten last dates results by
 COD, DATE, NAME or FILE. So, when I click in some os then, I need to ORDER
 the TEN DATES, not the entire table and give ten results, did you get it?

So you want your query to have 'ORDER BY DATE,COD' ??
--
Michael T. Babcock
CTO, FibreSpeed Ltd. (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/

-
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




RES: RES: SQL Select Idea

2002-12-04 Thread Felipe Moreno - MAILING LISTS
Hi Michael,

   Well, the SQL Query you requested is exatcly the one I'm asking! :-)
   Like I said in other message, I solved the problem using TWO queries. In
the first one I get the 10th date. In the second one I use this date to
LIMIT the result to what I want. But is not a question of solving the
problem, but a question for a better designed query. I just want to use 1
(one) select to do the same thing that the two selects above do, if it is
possible of course. Below, I will show you the actual scenary, and after,
the question, how can I optimize it to use just one select?. If I can get
the value of the LAST index, I can subtract 10 indexes from this value and
get only this range of values, doing this I will get the last ten dates
without the LIMIT 0,10 that don't give me what I want.

Actual scenary:

// This is the main select that give me the last ten dates.

$sql = select pa.codigo,arquivo,label,tipo,DATE_FORMAT(data,'%d/%m/%Y -
%H:%i') as ndata,RS,ref_wicie from processo_arquivos as pa,cliente as
c,processo as p where pa.codigocliente=c.codigo and
pa.codigoprocesso=p.codigo ;


// This is the FIRST select that catch the LIMIT date

$sql2 = select data from processo_arquivos as pa,cliente as c,processo as
p where pa.codigocliente=c.codigo and pa.codigoprocesso=p.codigo order by
data desc limit 0,11;
$conexao-Query($sql2,$this-banco,$this-valor);
$i = 0;
if ($conexao-Select($this-banco)){
while (($this-valor = 
mysql_fetch_array($this-banco))  ($i10)){
$i++;
}
$dataLimite = $this-valor['data'];
$sql .=  and data'.$dataLimite.' ;   --- Here I 
select the last
ten dates.
}

What I wanted:

--- ??? 
Just do what I'm doing above using only ONE select.

Any tips?


Best Regards,

Felipe


-Mensagem original-
De: Michael T. Babcock [mailto:[EMAIL PROTECTED]]
Enviada em: quarta-feira, 4 de dezembro de 2002 02:06
Para: [EMAIL PROTECTED]
Assunto: Re: RES: SQL Select Idea


On Tue, Dec 03, 2002 at 07:02:02PM -0200, Felipe Moreno - MAILING LISTS
wrote:
 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)

[ that worked as described ]

 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:

[ you didn't give the EXACT SQL QUERY that you're typing in; please give
it ]

I'm assuming that you're forgetting a step, or misunderstanding a step
involved.  Are you doing anything with that data you're selecting, or just
selecting it and leaving it?  You might be wanting to select it into a new
table or something; look up INSERT INTO ... SELECT FROM 
--
Michael T. Babcock
CTO, FibreSpeed Ltd. (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/

-
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




SQL Select Idea

2002-12-03 Thread Felipe Moreno - MAILING LISTS
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




MySQL: Select HELP!

2002-12-03 Thread Felipe Moreno - MAILING LISTS
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




RES: SQL Select Idea

2002-12-03 Thread Felipe Moreno - MAILING LISTS
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