mysql> insert into moo values ('moo1'); Query OK, 1 row affected (0.00 sec) mysql> select count(1) as npple, substring(fish,1, 3) as ra from moo group by ra order by npple; +-------+------+ | npple | ra | +-------+------+ | 3 | fis | | 4 | moo | +-------+------+ 2 rows in set (0.00 sec) mysql> select count(1) as npple, substring(fish, -2, 1) as ra from moo group by ra order by npple; +-------+------+ | npple | ra | +-------+------+ | 7 | | +-------+------+ 1 row in set (0.00 sec) mysql> select substring(fish, -2, 1) from moo; +------------------------+ | substring(fish, -2, 1) | +------------------------+ | h | | h | | h | | o | | o | | o | | o | +------------------------+ 7 rows in set (0.00 sec) mysql> select count(1) as npple, substring(fish, -2, 1) as ra from moo group by ra order by npple; +-------+------+ | npple | ra | +-------+------+ | 7 | | +-------+------+ 1 row in set (0.00 sec)