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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:30:43+00:00 2026-05-18T04:30:43+00:00

I have an old database with a gazillion records (more or less) that have

  • 0

I have an old database with a gazillion records (more or less) that have a single tags column (with tags being pipe-delimited) that looks like so:

    Breakfast
    Breakfast|Brunch|Buffet|Burger|Cakes|Crepes|Deli|Dessert|Dim Sum|Fast Food|Fine Wine|Spirits|Kebab|Noodles|Organic|Pizza|Salad|Seafood|Steakhouse|Sushi|Tapas|Vegetarian
    Breakfast|Brunch|Buffet|Burger|Deli|Dessert|Fast Food|Fine Wine|Spirits|Noodles|Pizza|Salad|Seafood|Steakhouse|Vegetarian
    Breakfast|Brunch|Buffet|Cakes|Crepes|Dessert|Fine Wine|Spirits|Salad|Seafood|Steakhouse|Tapas|Teahouse
    Breakfast|Brunch|Burger|Crepes|Salad
    Breakfast|Brunch|Cakes|Dessert|Dim Sum|Noodles|Pizza|Salad|Seafood|Steakhouse|Vegetarian
    Breakfast|Brunch|Cakes|Dessert|Dim Sum|Noodles|Pizza|Salad|Seafood|Vegetarian
    Breakfast|Brunch|Deli|Dessert|Organic|Salad
    Breakfast|Brunch|Dessert|Dim Sum|Hot Pot|Seafood
    Breakfast|Brunch|Dessert|Dim Sum|Seafood
    Breakfast|Brunch|Dessert|Fine Wine|Spirits|Noodles|Pizza|Salad|Seafood
    Breakfast|Brunch|Dessert|Fine Wine|Spirits|Salad|Vegetarian

Is there a way one could retrieve each tag and insert it into a new table tag_id | tag_nm using MySQL only?

  • 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-18T04:30:43+00:00Added an answer on May 18, 2026 at 4:30 am

    After finding there is no official split function I’ve solved the issue using only MySQL like so:

    1: I created the function strSplit

    CREATE FUNCTION strSplit(x varchar(21845), delim varchar(255), pos int) returns varchar(255)
    return replace(
    replace(
    substring_index(x, delim, pos),
    substring_index(x, delim, pos - 1),
    ''
    ),
    delim,
    ''
    );
    

    Second I inserted the new tags into my new table (real names and collumns changed, to keep it simple)

    INSERT IGNORE INTO tag (SELECT null, strSplit(`Tag`,'|',1) AS T FROM `old_venue` GROUP BY T)
    

    Rinse and repeat increasing the pos by one for each collumn (in this case I had a maximum of 8 seperators)

    Third to get the relationship

    INSERT INTO `venue_tag_rel` 
    (Select a.`venue_id`, b.`tag_id` from `old_venue` a, `tag` b 
         WHERE 
         (         
         a.`Tag` LIKE CONCAT('%|',b.`tag_nm`) 
         OR a.`Tag` LIKE CONCAT(b.`tag_nm`,'|%') 
         OR a.`Tag` LIKE CONCAT(CONCAT('%|',b.`tag_nm`),'|%') 
         OR  a.`Tag` LIKE b.`tag_nm`
         ) 
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old Access database that is being upgraded to work with Access
I Have a old database to maintain .... they have stored html tags in
I have an old database and a new database. The old records were converted
I have an old SQL Server 2000 database that I want to get into
I have a database with a lot of old phpBB data that contains posts
I have a CGI script that uses an old database driver that is no
I have an old database that I am inheriting. The access rights are not
The problem I have is that I have an old database where there typically
We have a pile of old databases in archives that have a column named
I have a complex database conversion console app that reads from an old database,

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.