Re: "Natural" Sort
So here's one way to sort alphanumeric values without a delimiter - I'm not sure if it's the best.
drop table tmp;
create table tmp (name char(10));
insert into tmp values ('AIYC1'), ('AIYC10'), ('AIYC2'), ('ABC1'), ('ABC2'), ('ABC10'), ('ABC30');
insert into tmp values ('tmp.10'), ('tmp.3'), ('emp-22'),('emp-7'),('emp-6a'),('emp-6b'),(45),(7);
--check the maximum length of the field
select max(length(name)) from tmp;
-- and then write a conditional up to that number
select name from tmp
ORDER BY left(name,
(CASE when substr(name,1) between '0' and '9' then 1
when substr(name,2) between '0' and '9' then 2
when substr(name,3) between '0' and '9' then 3
when substr(name,4) between '0' and '9' then 4
when substr(name,5) between '0' and '9' then 5 ELSE 6 end)-1),
0+substr(name,
CASE when substr(name,1) between '0' and '9' then 1
when substr(name,2) between '0' and '9' then 2
when substr(name,3) between '0' and '9' then 3
when substr(name,4) between '0' and '9' then 4
when substr(name,5) between '0' and '9' then 5 ELSE 6 end);
+--------+
| name |
+--------+
| 7 |
| 45 |
| ABC1 |
| ABC2 |
| ABC10 |
| ABC30 |
| AIYC1 |
| AIYC2 |
| AIYC10 |
| emp-6a |
| emp-6b |
| emp-7 |
| emp-22 |
| tmp.3 |
| tmp.10 |
+--------+
Chris