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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:23:16+00:00 2026-06-12T22:23:16+00:00

I have a table used for lookups which stores the human-readable value in one

  • 0

I have a table used for lookups which stores the human-readable value in one column and a the same text stripped of special characters and spaces in another. e.g., the value “Children’s Shows” would appear in the lookup column as “childrens-shows”.

Unfortunately the corresponding main table isn’t quite that simple – for historical reasons I didn’t create myself and now would be difficult to undo, the lookup value is actually stored with surrounding asterisks, e.g. ‘*childrens-shows*’.

So, while trying to join the lookup table sans-asterisks with the main table that has asterisks, I figured CONCAT would help me add them on-the-fly, e.g.;

    SELECT * 
      FROM main_table m 
INNER JOIN lookup_table l 
        ON l.value = CONCAT('*',m.value,'*')

… and then the table was toast. Not sure if I created an infinite loop or really screwed the data, but it required an ISP backup to get the table responding again. I suspect it’s because the ‘*’ symbol is probably reserved, like a wildcard, and I’ve asked the database to do the equivalent of licking its own elbow. Either way, I’m hesitant to ‘experiment’ to find the answer given the spectacular way it managed to kill the database.

Thanks in advance to anyone who can (a) tell me what the above actually did to the database, and (b) how I should actually join the tables?

  • 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-12T22:23:18+00:00Added an answer on June 12, 2026 at 10:23 pm

    When using CONCAT, mysql won’t use the index. Use EXPLAIN to check this, but a recent problem I had was that on a large table, the indexed column was there, but the key was not used. This should not bork the whole table however, just make it slow. Possibly it ran out of memory, started to swap and then crashed halfway, but you’d need to check the logs to find out.

    However, the root cause is clearly bad table design and that’s where the solution lies. Any answer you get that allows you to work around this can only be temporary at best.

    Best solution is to move this data into a separate table. ‘Childrens shows’ sounds like a category and therefore repeated data in many rows. This should really be an id for a ‘categories’ table, which would prevent the DB from having to run CONCAT on every single row in the table, as you could do this:

        SELECT * 
          FROM main_table m 
    INNER JOIN lookup_table l 
            ON l.value = m.value
       /* and optionally */
    INNER JOIN categories cat
            ON l.value = cat.id
         WHERE cat.name = 'whatever'
    

    I know this is not something you may be able to do given the information you supplied in your question, but really the reason for not being able to make such a change to a badly normalised DB is more important than the code here. Without either the resources or political backing to do things the right way, you will end up with even more headaches like this, which will end up costing more in the long term. Time for a word with the boss perhaps 🙂

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

Sidebar

Related Questions

I have a oracle table A which contains a column A.a which used to
Basically I have a table which is used to hold employee work wear details.
Given I have table with some data... I have a query which is used
I have this JSF table which is used to display data. I want to
I have a table A which references table B. edit: Database engine used is
Informix 11.70.TC4: I have an SQL dimension table which is used for looking up
We have a table that is used for assessment-values in our tool where each
I used JPA and mysql. Each table have entity class.I have four tables. Table1
I have a huge table that is mainly used for backup and administrative purposes.
I have a pretty common layout issue that I have traditionally used a table

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.