* Giulio > I have a table, let's call it item, which has a field containing a > comma separated list of IDs of related items ( same table ). > > I know, this is far away from a correctly normalized structure and this > stuff should be handled using another table for the link, but I'm > working on a pre-existent environment and I would like not to change > it. > > the question is, is there a way to retrieve the related items in the > same order their ID are present on the field? > > I mean, having a 'related_items_ID' field containing '12,101,7,4', is > there some workaround to have a returned recordset with record 12 on > the first row, 101 on the second, and so on, , or must I handle this by > code?
Try somthing like: ... ORDER BY FIND_IN_SET(related_items_ID,'12,101,7,4'); <URL: http://dev.mysql.com/doc/mysql/en/String_functions.html#IDX1272 > -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]