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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:53:01+00:00 2026-06-17T18:53:01+00:00

I have a special data environment where I need to be returned data in

  • 0

I have a special data environment where I need to be returned data in a certain way to populate a table.

This is my current query:

SELECT 
  bs_id, 
  IF(bs_board = 0, 'All Boards', (SELECT b_name FROM certboards WHERE b_id IN (REPLACE(bs_board, ';', ',')))) AS board 
FROM boardsubs

As you can see I have an if statement then a special subselect.

The reason I have this is that the field bs_board is a varchar field containing multiple row IDs like so:

1;2;6;17

So, the query like it is works fine, but it only returns the first matched b_name. I need it to return all matches. For instance in this was 1;2 it should return two boards Board 1 and Board 2 in the same column. Later I can deal with adding a <br> in between each result.

But the problem I am dealing with is that it has to come back in a single column both name, or all names since the field can contain as many as the original editor selected.

  • 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-17T18:53:02+00:00Added an answer on June 17, 2026 at 6:53 pm

    This will not work the way you’re thinking it will work.

    Let’s say bs_board is '1;2;3'

    In your query, REPLACE(bs_board, ';', ',') will resolve to '1,2,3', which is a single literal string. This makes your final subquery:

    SELECT b_name FROM certboards WHERE b_id IN ('1,2,3')
    

    which is equivalent to:

    SELECT b_name FROM certboards WHERE b_id = '1,2,3'
    

    The most correct solution to the problem is to normalize your database. Your current system or storing multiple values in a single field is exactly what you should never do with an RDBMS, and this is exactly why. The database is not designed to handle this kind of field. You should have a separate table with one row for each bs_board, and then JOIN the tables.

    There are no good solutions to this problem. It’s a fundamental schema design flaw. The easiest way around it is to fix it with application logic. First you run:

    SELECT bs_id, bs_board FROM boardsubs
    

    From there you parse the bs_board field in your application logic and build the actual query you want to run:

    SELECT bs_id, 
      IF(bs_board = 0, 'All Boards', (SELECT b_name FROM certboards WHERE b_id IN (<InsertedStringHere>) AS board 
    FROM boardsubs
    

    There are other ways around the problem, but you will have problems with sorting order, matching, and numerous other problems. The best solution is to add a table and move this multi-valued field to that table.

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

Sidebar

Related Questions

So I have been writing to Environment.SpecialFolder.ApplicationData this data file, that upon uninstall needs
I want to render for facebook bot special data. I have og.html.erb <!DOCTYPE html><html><head>
I'm trying to query by iteration but our iteration names have special characters (e.g.
Does ** have any special meaning in C? Like this: static intparse_one (int argc,
I have a special data storage ( Empire RDF ) I would like to
Is the Java String data that I will fetch complete if I have special
I have some special characters in my data inside xml.So i am getting error
When I extract data from a MySQL database, some of the output have special
I have the data table that is read from csv file. Then it is
I have special implementation for my grid. For this I wrote some code in

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.