shadedecho
Programmer
So, let's say I had a table (call that "bar") that had one column in it, and like 5 rows, each with a different string value, like 'abc', 'def', ... etc.
I could LEFT JOIN against "bar" from another table (call that "foo"), which only happens to have a subset of those string values as rows in it. What I'd get is a result set that had *all* the string values, one in each row, even if it only appeared in "bar" but not "boo".
Since the values in the theoretical "bar" table are finite (at most 5 or 6), I'd like to avoid needing that actual lookup table, and instead accomplish the above by replacing a reference to "bar" in my LEFT JOIN with a *subquery* that somehow returns a set of rows, one with each of the finite values.
I'm having trouble figuring out how to construct this subquery in such a way that it returns the finite values vertically (that is, as rows) instead of as columns, or inside an IN operator, or something like that.
For instance, you can do a query like this:
SELECT 1;
with no table or where or anything. So, I want a query that can do something like that, but return more than one row, as explicit finite values and not drawing from a table.
Anyone have any thoughts about this?
I could LEFT JOIN against "bar" from another table (call that "foo"), which only happens to have a subset of those string values as rows in it. What I'd get is a result set that had *all* the string values, one in each row, even if it only appeared in "bar" but not "boo".
Since the values in the theoretical "bar" table are finite (at most 5 or 6), I'd like to avoid needing that actual lookup table, and instead accomplish the above by replacing a reference to "bar" in my LEFT JOIN with a *subquery* that somehow returns a set of rows, one with each of the finite values.
I'm having trouble figuring out how to construct this subquery in such a way that it returns the finite values vertically (that is, as rows) instead of as columns, or inside an IN operator, or something like that.
For instance, you can do a query like this:
SELECT 1;
with no table or where or anything. So, I want a query that can do something like that, but return more than one row, as explicit finite values and not drawing from a table.
Anyone have any thoughts about this?