Re: mysql top 2 rows for each group

2005-04-29 Thread SGreen
Vivian, Mathias was correct. I will be building on Mathias's answer by using your PK for your original data table (since you neglected to name it I will call it "source_table") WITH THE ASSUMPTION that you cannot change your data structure and that you already have a PK on the table: Create a

Re: mysql top 2 rows for each group

2005-04-29 Thread Vivian Wang
I did like this, look good, anyone can try it. set @a:=0; set @b:=0; update test set item=if([EMAIL PROTECTED], @a:[EMAIL PROTECTED], if(@b:=seqno, @a:=1, 0)); Vivian Wang wrote: I don't have any PK in this table, but If you like one, I can add another column for PK, like, ++---+ | id

Re: mysql top 2 rows for each group

2005-04-29 Thread mfatene
Hi, have you read my answer yesterday ? Mathias Selon Vivian Wang <[EMAIL PROTECTED]>: > I don't have any PK in this table, but If you like one, I can add > another column for PK, like, > ++---+ > | id | seqno | > ++---+ > | 1 | 00122 | > | 2 | 00123 | > |

Re: mysql top 2 rows for each group

2005-04-29 Thread Vivian Wang
I don't have any PK in this table, but If you like one, I can add another column for PK, like, ++---+ | id | seqno | ++---+ | 1 | 00122 | | 2 | 00123 | | 3 | 00123 | | 4 | 00123 | | 5 | 00336 | | 6 | 00346 | | 7 | 00349 | | 8 | 00

RE: mysql top 2 rows for each group

2005-04-28 Thread mathias fatene
7;Vivian Wang'; mysql@lists.mysql.com Subject: RE: mysql top 2 rows for each group Hi , The table must be myisam. Innodb refused my solution which is here : Beatifull auto_increment mysql> create table seqs(seqno varchar(10) NOT NULL , i

RE: mysql top 2 rows for each group

2005-04-28 Thread SGreen
"Jay Blanchard" <[EMAIL PROTECTED]> wrote on 04/28/2005 04:24:23 PM: > [snip] > I have question about how I can get top 2 rows for each group. > like I have table test > | seqno | > +---+ > | 00122 | > | 00123 | > | 00123 | > | 00123 | > | 00336 | > | 00346

RE: mysql top 2 rows for each group

2005-04-28 Thread mathias fatene
--- I like this type of auto_increment Best Regards Mathias FATENE Hope that helps *This not an official mysql support answer -Original Message----- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: jeudi 28 avril 2005 22:24 To: Vivian Wang; mysql@lists.mysql.c

RE: mysql top 2 rows for each group

2005-04-28 Thread Jay Blanchard
[snip] I have question about how I can get top 2 rows for each group. like I have table test | seqno | +---+ | 00122 | | 00123 | | 00123 | | 00123 | | 00336 | | 00346 | | 00349 | | 00427 | | 00427 | | 00427 | +---+--+ I like have