0

I know I can select a single value using

SELECT 'value' AS col;

But I need return a list of numbers as a column. Something like

SELECT ('value1', 'value2', 'value3') AS col;

More precisely I need to do

SELECT * FROM my_table
INNER JOIN (SELECT ('value1', 'value2', 'value3') AS col ) AS x ON my_table.id = x.col

Does someone know how can I do it?

****EDIT****

Let me explain my problem with more details, maybe you can suggest a different method to solve it.

I have the following table

+--------+--------+------+
| tb1_id | tb2_id | main |
+--------+--------+------+
|     15 |  81123 |    1 |
|     16 |  81599 |    1 |
|     17 |  82101 |    0 |
|     17 |  82102 |    1 |
|     18 |  82101 |    0 |
|     18 |  82102 |    0 |
|     18 |  82103 |    1 |
+--------+--------+------+

I need to build a query that return something like this:

+--------+--------+---------------+
| tb1_id | main   | assoc         |
+--------+--------+---------------+
| 15     | 81123  |               |
| 16     | 81599  |               |
| 17     | 82102  |  82101        |
| 18     | 82103  |  82102, 82101 |
+--------+--------+---------------+

Currently I'm using a subquery to get the result, but I'm having performance issues.

0 Answers0