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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:02:25+00:00 2026-05-31T00:02:25+00:00

I have a MySQL table with just a single text type column with lots

  • 0

I have a MySQL table with just a single text type column with lots of information in the same format, starting with a string like this:

Field1 : 1234
Field2 : Something

The column always starts with Field1 and Field2, but the values after each Field are different for each record.

What I need is to get the just the values of what’s after Field1 and Field2 (in this case 1234 and Something) on a Query, the value after Field1 is easy because it’s always 4 characters long, but the problem is the one after Field2 because it’s size varies for each record, what I have so far is this:

SELECT SELECT substring(substring_index(COLUMN,'Field1 : ',-1),1,4) as Field1_value
FROM table

I know after Field2‘s value there’s a line break, so I’ll think of considering the \n character to delimit the value I need.

How do I get this substring of variable size for each row?

P.S. Yes the data is horribly structured, I’m not able to change it…

  • 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-31T00:02:26+00:00Added an answer on May 31, 2026 at 12:02 am

    Well, finally I got it (thanks for your contributions everybody), this is the final resulting Query:

    select substring(subcolumn, 9,5) as Field1, 
        substring(subcolumn,  24) as Field2 
        from (        
            select substring(COLUMN, 1, locate('\n',COLUMN,15)) as subcolumn
            from table
    ) as X
    

    Knowing the size of the strings “Field1 : ” and “Field2 : “, this isolates those 2 strings and their following values from the rest of column’s text, and then I use a substring (knowing that the value after Field1 is always 4 characters long helps), and the 15 in the substring is to ensure I look not for the second line break.

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

Sidebar

Related Questions

I have mysql table that has a column that stores xml as a string.
I have a MySQL table with a column of well-formed URLs. I'd like to
I have a MySQL table holding lots of records that i want to give
I have a mysql table with my users... each user has various attributes like
I have a MySQL table named contentcontaining (a.o.) the fields _date and text, for
I have a MySQL table with approximately 3000 rows per user. One of the
I have a MySQL table containing domain names: +----+---------------+ | id | domain |
I have a MySQL table LOGIN_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION
I have a mysql table that relies on the unix epoch time stamp equivalent
I have a MySQL table consisting of: CREATE TABLE `url_list` ( `id` int(10) unsigned

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.