0

I know how to do a fetch array to create a while loop as well as the mysql query in ASC order.

What I'm trying to sort out is how I might be able to make it create the ASC order but to ignore the initial words "The" or "A" in the results

example if the records have

-Running Around
-The End Game
-A Robotic Arm
-Mighty Mouse

I want the result to show

  1. The End Game
  2. Might Mouse
  3. A Robotic Arm
  4. Running Around

when it shows me the listed results in ASC order

Thanks for your time and help

2
Contributors
2
Replies
53
Views
1 Month
Discussion Span
Last Post by wikit
2
order by
    if(
        substr(`ord_column`, 1, 2)='A ',
        substr(`ord_column`, 3),
        if(
            substr(`ord_column`, 1, 4)='The ',
            substr(`ord_column`, 5),
            `ord_column`
            )
        )

or mutch readable (result will be same)

order by
    case
        when substr(`ord_column`, 1, 2)='A ' then substr(`ord_column`, 3)
        when substr(`ord_column`, 1, 4)='The ' then substr(`ord_column`, 5)
        else `ord_column`
    end

Edited by AndrisP

0

Not sure how to mark something as solved but it is ... thankyou AndrisP

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.