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.