Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4066742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:09:53+00:00 2026-05-20T16:09:53+00:00

I have a mysql query which outputs 6 columns of related data, I’m specifically

  • 0

I have a mysql query which outputs 6 columns of related data, I’m specifically interested in having the results sorted alphabetically by a certain modified column. The unmodified results from that column look like this:

... | 0001: Some text here        |...
... | 0002: Flipped text here     |...
... | 0003: About some more text  |...

The ‘0001:’ portion should not be displayed. Currently, I have a Perl subroutine which removes that portion from being displayed, but I don’t know how I can get all rows sorted alphabetically based off of that resulting column. What I’m looking for would be:

... | About some more text  |...
... | Flipped text here     |...
... | Some text here        |...

The following is what I’m using to retrieve and display said data, but my understanding of Perl is sorely lacking. I don’t understand how the @$data works, just know that it does. My failed sorting attempt is commented out by the #.

$data = $sth->fetchall_arrayref();
$sth->finish;

foreach $data ( @$data) {
    ($a, $name, $c, $d, $e, $f) = @$data;
    # @$data = sort { "\L$a->out_name([2])" cmp "\L$b->out_name([2])"} @$data;
    $Response->Write($a.",".out_name($name).",".$c.",".$d.",".$e.",".$f."<br />");
}

Any help or ideas would be greatly appreciated, thank you.

EDIT: I failed to note, the ‘0001:’ portion may appear as ‘511:’ or ‘85000:’, that number isn’t a constant length. If there’s a way to deal with this condition in Mysql, that would be excellent. It didn’t seem like a possibility in my searches, thus why I was attempting it with Perl.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:09:54+00:00Added an answer on May 20, 2026 at 4:09 pm

    You can get the database to do the sorting for you:

    SELECT ...
    FROM yourtable
    ORDER BY SUBSTR(yourcolumn, 5)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have a small query which takes data from one mysql database and
I have one main array which is the returned data from a MySQL query
I have the following mysql query which I am running with php like so.
I have a complicated MySQL query which takes a lot of time, selecting from
I have one mysql query, which gets rows to designs list. In this list
I have the following mysql query, which is producing a list of entries by
I have this query which works correctly in MySQL. More background on it here
I have a query which works fine in MySQL, but when I run it
Hi I have a query which is very straightforward to write in mysql but
I have a big mysql query which needs to trawl through 4 tables to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.