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 7905143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:21:54+00:00 2026-06-03T10:21:54+00:00

How can I order by dash? For instance, I have these data below, page_id

  • 0

How can I order by dash?

For instance, I have these data below,

page_id   url
1         - a
2         - b
3         --- c
4         --- d
5         - e
6         - f
7         -- g
8         -- h

Result that I am after,

page_id   url
1         - a
2         - b
5         - e
6         - f
7         -- g
8         -- h
3         --- c
4         --- d

If I do this,

ORDER by x.url ASC

I still get this,

page_id   url
1         - a
2         - b
3         --- c
4         --- d
5         - e
6         - f
7         -- g
8         -- h

Any ideas?

EDIT:

My actual SQL,

SELECT 
    *,
    IF(grandparentURL REGEXP '^[a-z0-9\-]+$', CONCAT('--- ', url), IF(parentURL REGEXP '^[a-z0-9\-]+$', CONCAT('-- ', url), CONCAT('- ', url))) AS url
FROM
(
    SELECT 
        p.page_id,
        p.url,
        p2.url AS parentURL,
        p3.url AS grandparentURL

    FROM page AS p

    LEFT JOIN page AS p2 
    ON p.parent_id = p2.page_id AND p.page_id != p2.page_id

    LEFT JOIN page AS p3 
    ON p2.parent_id = p3.page_id AND p2.page_id != p3.page_id

    WHERE IF('5' REGEXP '^[0-9]+$', p.page_id != '5', p.page_id IS NOT NULL)
    AND p.url != 'cms' 
) x

ORDER by x.url ASC
  • 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-06-03T10:21:55+00:00Added an answer on June 3, 2026 at 10:21 am

    Do MULTIPLE order by… FIRST by the position where space is found first all grouped… from that, then sort by the entire URL. Since the common – b and – a will be in the same grouping, their space keeps them in group “1”… then, from that, the entire URL will force your proper – a, – b, – c, etc

    ORDER BY INSTR('x.url', ' '), x.url
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that I can order a data.frame as such: test = data.frame(A=c(4,2,4), B=c(8,3,2))
I am designing an app that tracks orders. Each order can have > 1
Simply, I have this SQL statment: EXEC xp_cmdshell 'tasklist' can we order or filter
My Application currently serves requests for data, and can order the data to the
I don't think that I can use ORDER BY clause inside the GROUP_CONCAT function.
In cake php is how we can get order of query result according to
I have many Topic objects and each Topic hasMany posts:Post How can I order
I would like to know what solution I can use in order to have
I have some SQL that does an order by case statement. It works fine.
I have a form for creation new order. One order can include several products.

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.