Jump to content

Archived

This topic is now archived and is closed to further replies.

yrrahxob

Select order by substr of a field

Recommended Posts

I have the following query but it doesn\'t work. I get error code 1064.

 

SELECT * FROM `aud_desc` order by substr(aud_code,1,1)

 

Is it possible to do a select and order it by a substr of a column.

 

Please help

 

Thank you

Share this post


Link to post
Share on other sites

In MySQL use the SUBSTRING() function.

 

SELECT * FROM aud_desc ORDER BY SUBSTRING(aud_code, 1, 1);

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.