On Tue, 24 May 2005 [EMAIL PROTECTED] wrote: >Hi, >try for axample, > >select PK, ord(GRP_COL),COL from your_table;
When I said my data was 'like' the below I should have been more specific. Here is some of my data (with reference to the simplified data (and question details) below); INPUT: <----PK-----> <------GRP_COL--------> +------+-----+-------------+--------+ | PDB | ASS | LIST | COUNTS | +------+-----+-------------+--------+ | 104l | 1 | 104lA | 1 | | 104l | 2 | 104lA | 1 | | 104m | 1 | 104m- | 1 | | 105m | 1 | 104m- | 1 | | 117e | 1 | 117eA | 2 | | 11ba | 1 | 11baA | 2 | | 11bg | 1 | 11baA | 2 | | 12e8 | 1 | 12e8H,12e8L | 2,2 | | 12e8 | 2 | 12e8H,12e8L | 2,2 | ... OUTPUT (wanted): <--------FK--------> <----PK-----> +---------+---------+------+-----+ | REP_PDB | REP_ASS | PDB | ASS | +---------+---------+------+-----+ | 104l | 1 | 104l | 1 | | 104l | 1 | 104l | 2 | | 104m | 1 | 104m | 1 | | 104m | 1 | 105m | 1 | | 117e | 1 | 117e | 1 | | 11ba | 1 | 11ba | 1 | | 11ba | 1 | 11bg | 1 | | 12e8 | 1 | 12e8 | 1 | | 12e8 | 1 | 12e8 | 2 | ... Cheers, > > >Mathias > >Selon Dan Bolser <[EMAIL PROTECTED]>: > >> >> Hello, >> >> I have data like this >> >> PK GRP_COL >> 1 A >> 2 A >> 3 A >> 4 B >> 5 B >> 6 B >> 7 C >> 8 C >> 9 C >> >> >> And I want to write a query to select data like this... >> >> PK FK GRP_COL >> 1 1 A >> 2 1 A >> 3 1 A >> 4 4 B >> 5 4 B >> 6 4 B >> 7 7 C >> 8 7 C >> 9 7 C >> >> >> Where FK is a random (or otherwise) member of PK from within the >> appropriate group given by GRP_COL. FK recreates the grouping from >> GRP_COL, but in terms of PK. I want to do this because GRP_COL is >> difficult to handle and I want to re-represent the grouping in terms of PK >> (this allows me to link data into the grouping more easily). >> >> Is there a simple way to do this? >> >> >> >> -- >> MySQL General Mailing List >> For list archives: http://lists.mysql.com/mysql >> To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] >> >> > > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]