Andrew Braithwaite wrote:
Is there any way to get MySQL to return the results of this query with
the 'fieldname' in the order listed in the in() bit?
select fieldname from tablename where fieldname in
('B4079','B4076','B4069','B4041','A4710','58282','58220','56751','56728'
,'45003','09234','04200','04035','04026');
Yes, try the FIND_IN_SET() or the FIELD() function:
select fieldname
from tablename
where fieldname in
('B4079','B4076','B4069','B4041',
'A4710','58282','58220','56751','56728',
'45003','09234','04200','04035','04026')
order by
FIELD(fieldname,'B4079','B4076','B4069','B4041',
'A4710','58282','58220','56751','56728',
'45003','09234','04200','04035','04026');
<URL: http://dev.mysql.com/doc/mysql/en/string-functions.html >
--
Roger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]