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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:50:14+00:00 2026-05-23T18:50:14+00:00

I’ll try to detail this the best I can. I have a nested select

  • 0

I’ll try to detail this the best I can. I have a nested select statement with a where in clause, but the nested part of the select should be interpreted as a literal string (I believe this is the right terminology). However the default behavior of mysql leads to a result I do not want.

I.e.

select class 
from cs_item 
where code="007"

+-------+
| class |
+-------+
| 1,3   |
+-------+

And the below is a query if I explicitly type “in (1,3)” as part of a select query:

select alpha,description 
from cs_quality 
where class in (1,3);

+-------+-------------+
| alpha | description |
+-------+-------------+
| STD   | STD         |
| XS    | XS          |
| 5     | Sch 5       |
| 10    | Sch 10      |
| 20    | Sch 20      |
| 40    | Sch 40      |
| 60    | Sch 60      |
| 80    | Sch 80      |
| 100   | Sch 100     |
| 120   | Sch 120     |
| 140   | Sch 140     |
| 160   | Sch 160     |
| XXS   | XXS         |
| 15L   | 150#        |
| 30L   | 300#        |
| 40L   | 400#        |
| 60L   | 600#        |
| 90L   | 900#        |
| 150L  | 1500#       |
| 200L  | 2000#       |
| 250L  | 2500#       |
| 300L  | 3000#       |
| 400L  | 4000#       |
| 600L  | 6000#       |
| 900L  | 9000#       |
+-------+-------------+

But when I go to nest this to get the same result I have…

select alpha,description 
from cs_quality 
where class in (select class from cs_item where code = "007")

+-------+-------------+
| alpha | description |
+-------+-------------+
| STD   | STD         |
| XS    | XS          |
| 5     | Sch 5       |
| 10    | Sch 10      |
| 20    | Sch 20      |
| 40    | Sch 40      |
| 60    | Sch 60      |
| 80    | Sch 80      |
| 100   | Sch 100     |
| 120   | Sch 120     |
| 140   | Sch 140     |
| 160   | Sch 160     |
| XXS   | XXS         |
+-------+-------------+

Which is just the part of “class in 1″… it balks on the “,3” component. Is there a way for the nested select to be interpreted as literal text?

Thanks all, much appreciated. I had a bit of trouble wording this question but will edit as needed.

  • 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-23T18:50:15+00:00Added an answer on May 23, 2026 at 6:50 pm

    Normalize, normalize, normalize your tables, in this case table cs_item. You should NOT store multiple (comma separated) values in one field.

    Until you do that, you can use:

    select alpha, description 
    from cs_quality 
    where FIND_IN_SET( class , (select class from cs_item where code = '007'))
    

    or

    select q.alpha, q.description 
    from cs_quality AS q
      join cs_item AS i
        on FIND_IN_SET( q.class , i.class )
    where i.code = '007'
    

    But this kind of using special functions instead of equality for JOINs, leads to very slow queries. Storing comma separated lists leads to a ton of other problems. See here:

    • Is storing a comma separated list in a database column really that bad?

    Short answer is: Yeah, it’s that bad.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and

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.