On Tue, 15 Mar 2005 17:43:29 -0600, [EMAIL PROTECTED] wrote: > > I need to do this: > From this table > +--------------+ > |id|Data | > |--|-----------| > | 1|Something 1| > | 2|Something 2| > | 3|Something 3| > | 4|Something 4| > | 5|Something 5| > | 6|Something 6| > +--------------+ > > Get this query > +-----------------------------+ > |id|Data |id|Data | > |--|-----------|--|-----------| > | 1|Something 1| 4|Something 4| > | 2|Something 2| 5|Something 5| > | 3|Something 3| 6|Something 6| > +-----------------------------+ > > Any idea?
Do this in whichever scripting language you are using. You can do this in SQL if your list of IDs is monotomously increasing (no gaps), but it is rather ugly: SELECT a.ID, a.Data, b.ID, b.Data FROM table a LEFT JOIN table b ON (a.ID + Ceiling((SELECT MAX(ID) FROM table) / 2) = b.ID) WHERE a.ID <= Ceiling((SELECT MAX(ID) FROM table) / 2) ORDER BY a.ID Jochem -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]