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

  • Home
  • SEARCH
  • 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 8100885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:51:19+00:00 2026-06-05T22:51:19+00:00

This question is related to another question, where I wanted to define a custom

  • 0

This question is related to another question, where I wanted to define a custom MySQL column format. The question is here: How to enforce custom MySQL column format.

The custom format that I want is always a 2 digit integer, followed by the # sign, then a space, then a decimal number with 2 digits after the decimal. Examples of allowed values are like this:

30# 11.00
27# 17.25
40# 17.25

values that are not allowed are like this:

30# 11
40# 20.5
27# 13

As you can see, the problem with the values that aren’t allowed is basically just the last decimal number is missing the “.” and trailing zeros. Is there some update syntax that I can use to fix all these incorrect column values? Basically I just need to check if the last decimal number after the “# ” have the 2 trailing decimal digits. If it doesn’t then I want to add the “.” and the trailing zeros. Does anyone know an UPDATE command that can do this?

Thanks!

EDIT

answers to some of the comments: Yes it is VARCHAR type column. If the value is completely different than what we want, then just leave it alone. Most of the problems are what I explained, and if i can fix all of those with one query then that is a good start.

  • 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-05T22:51:21+00:00Added an answer on June 5, 2026 at 10:51 pm
    update your_table
    set some_column = case when len(some_column) = 6
                           then some_column + '.00'
                           when len(some_column) = 8
                           then some_column + '0'
                      end
    where len(some_column) < 9;
    

    See this example

    here is some more precise syntax that worked very well:

    update your_table 
    set some_column =
    case 
        when length(some_column) = 6 
        then concat(some_column,".00") 
        when length(some_column) = 7
        then concat(some_column,"00") 
        when length(some_column) = 8
        then concat(some_column,"0") 
        else some_column 
    end 
    where some_column REGEXP '^[0-9][0-9]# [0-9][0-9]';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Another question related to this one . I have a List<SortableObjects> that is the
This is actually related to another question I had that was already answered. That
(This question is related to another one , but different enough that I think
This question is related to another I ask recently, it can be found here
This question is related to another question that I posted on SO earlier How
This is a question related to another one I asked that was specific to
This is very closely related to this other question , but that question wanted
I've asked another related question to this here: casting dynamic to static problem I've
This question is related to another question I asked Basically, I have 2 horizontally
This question is related to another question I just posted . I'm prepping for

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.