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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:14:49+00:00 2026-06-17T14:14:49+00:00

Possible Duplicate: MySQL – If It Starts With A Number Or Special Character Select

  • 0

Possible Duplicate:
MySQL – If It Starts With A Number Or Special Character
Select values that begin with a number

I’m trying to create an ORDER BY statement that checks to see if the column begins with a number, if it does it should add + 0 to the column. If not, it does not.

Something like this IF(title begins with number, title + 0, title)

Not sure how to go about this.

  • 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-17T14:14:51+00:00Added an answer on June 17, 2026 at 2:14 pm
    ORDER BY IF(title REGEXP '^[0-9]',title+0,title)
    

    But, that expression is going to return a numeric value; and since “title+0” is essentially equal to “title” (in terms of a numeric value comparison), I don’t think that’s going to do what you want it to.

    (The “+0” operation will add zero to the leading numeric portion of the string value, and return a numeric value; so the entire expression will be evaluated as a numeric value. Which means that the bare “title” will also be a numeric value, which will be returned as 0 if there is no leading numeric.

    So, that is essentially equivalent to:

    ORDER BY title+0
    

    In what order do you actually want the title values returned in? Do you want the rows returned in order by the leading numeric, and then by the title string?

    I’m thinking you want to order by the string value of title when there isn’t a leading numeric digit; otherwise, by the numeric value of leading numeric digits, and then the string value of title, so something like this might get you closer to what you want:

    ORDER BY title REGEXP '^[0-9]', title+0, title
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: MySQL Select Multiple VALUES lets say i have a group of number
Possible Duplicate: MySQL Orderby a number, Nulls last I need to order results in
Possible Duplicate: MySQL CURRENT_TIMESTAMP as DEFAULT I am trying to create table as CREATE
Possible Duplicate: MySQL Relationships I am trying to create a one to many relationship
Possible Duplicate: MySQL number of items within “in clause” In mysql or postgres, is
Possible Duplicate: MySQL query that computes partial sums ok, the question is not clear
Possible Duplicate: MySQL returns only one row In Terminal mysql> select image,title,price from test;
Possible Duplicate: MySQL wildcard in select … SELECT icon_* FROM images WHERE 1 I
Possible Duplicate: mysql auto_increment by 5? I have a table that will have a
Possible Duplicate: MySQL query using an array How to use an array of values

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.