On 11 Jul 2002, at 16:06, Dan Lamb wrote: > I'd like it to order like this: > > aristo 156 > aristo 222 > aristo 1001 > > How can I do this in MySQL? Is there a way to take the numbers into > account when using order by?
There are various ways to break up your strings and convert part to a number using MySQL SQL, depending on what assumptions we're allowed to make about the format of your strings and the size of your numbers. Jay Blanchard has posted one possibility. However, your sorting will be much faster (and can use indexes better) if you don't have to do such calculations for each row every time you want to sort. If you need to sort by a two-part key, then you really should split the key into two columns, make one VARCHAR and one SMALLINT (or whatever), and make an index on both. -- Keith C. Ivey <[EMAIL PROTECTED]> Tobacco Documents Online http://tobaccodocuments.org --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php