MySQL table sorting records - alphabetical before numeric

Hi,
I have some records in my MySQL table and when I order by products code (prodcode) I get the following results

P11A      
P11Br      
P11D      
P11G      
P12A.2    
P12A.3    
P14A      
P14B      
P14E      
P17M      
P18C      
P1A

Is it possible to have a mysql query where alphabetical characters have a higher priority than numeric, to produce results similar to below?

P1A  
P1A.1
P1A.2
P2B  
P2E  
P2H  
P2I  
P4A  
P6A  
P6B  
P9C  
P11A  
P11B  

Thanks in advance for you feedba
sabecsAsked:
Who is Participating?
 
Richard DavisSenior Web DeveloperCommented:
I don't know what your SELECT statement looks like, but if you try something like this, it might solve your issue.

SELECT * FROM some_table WHERE field_name = 'blah' ORDER BY prodcode + 0 ASC

Hope this helped. :)

~A~
0
 
tdotCommented:
Hi, sabecs
select numbers from whatever order by numbers + 0;
0
 
mkiredjianCommented:
Can you provide more details your table fields sample data from it the result you are getting the result you expect to get
0
 
sabecsAuthor Commented:
Thanks for your feedback, I need to sort prodcode where alphabetical characters are shown before numeric characters. For example in the list below, P1A & P1G should be at the top.
P11A      
P11Br      
P11D      
P11G      
P12A.2    
P12A.3    
P14A      
P14B      
P14E      
P17M      
P18C      
P1A
P1G

 
0
 
tdotCommented:
SELECT prodcodes FROM table WHERE field = 'something' ORDER BY prodcode  ASC
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.