[SOLVED] I'm trying to retrieve a record ORDER by id ASC...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

I'm trying to retrieve a record ORDER by id ASC...

Post by voltrader »

I'm trying to retrieve a record ORDER by id ASC, but my field is of the form:

x0000000000

where x is a letter.

Is there a MySQL command to ignore the first letter? Or does MySQL already consider A2 to be bigger than A1?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Code: Select all

SELECT id,SUBSTRING(id,2) AS id1
FROM `Table1`
ORDER BY id1

Code: Select all

SELECT GREATEST("A1","A2");
returns A2
Last edited by anjanesh on Mon Aug 09, 2004 2:07 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

A2 would be sorted after A1
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

[SOLVED] Thanks for replies folks
Post Reply