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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:02:34+00:00 2026-05-19T17:02:34+00:00

ex. c1, c2 = > result c1 c1 result 1 1 to 1000001 2

  • 0


 ex. c1, c2 = >  result

 c1       c1       result
 1         1       to  1000001
 2         9       to  2000009
 3         1       to  3000001
 21        34      to  2100034
 22        35      to  2200035
 23        55      to  2300055
 111       1234    to  1111234
 112       8392    to  1128392
 113       2833    to  1132833


 a part of my MySQL SELECT CONCAT() statement with cut out "c1" look like,


 IF(CHAR_LENGTH(`c2`)=1,  concat('00000',`c2`), 
   IF(CHAR_LENGTH(`c2`)=2, concat('0000',`c2`),
    IF(CHAR_LENGTH(`c2`)=3, concat('000',`c2`),
     IF(CHAR_LENGTH(`c2`)=4, concat('00',`c2`),
      IF(CHAR_LENGTH(`c2`)=5, concat('0',`c2`),`c2` )))))


But is there any other way to reduce this code for concat c1 with c1 into result with zero at the middle and with auto calculation of how many zeros have to be added?

  • 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-19T17:02:35+00:00Added an answer on May 19, 2026 at 5:02 pm

    There might be a math function to help you here, although I don’ t know if it is quicker.

    Lets see. you want to multiply a single value for c1 by 1000000 and then add c2.
    For the more general case, you want to multiply by

      1000000 / 10^(char_length(`c1`)-1)
    

    more:
    Your final value will be

    (c1 *  (1000000 / 10^(char_length(`c1`)-1))) + c2
    

    But that LPAD function from @eumiro might be a better answer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

... // result is a JSON data passed to this function from outside var
The result stored in $g is 1 and 2. The following code I've written
var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals
var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals
var result = db.PhotoAlbums.Select(albums => new PhotoAlbumDisplay { AlbumID = albums.AlbumID, Title = albums.Title,
What result is right for the following test cases? //Chrome 19 Opera 12 Firefox
How can I exclude result prefixes from an XQuery similiar to the XSLT exclude-result-prefixes
How do I display result of StringTokenizer object into JLabel s? I have few
What do the result codes in SVN mean? I need a quick reference.
Can someone explain this result to me. The first test succeeds but the second

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.