After running a job based on a customer query eg,
SELECT user_id FROM table1 where <conditions>
INTERSECT / INTERSECT ALL
SELECT user_id FROM table2 where <conditions>
I would like to store the user_id into a table which will be used in the future in this manner,
SELECT [attributes1, attributes2, attributes3] FROM table1 where user_id IN (...user_ids)
I am thinking what would be the best way to store the user Ids, the userIds will not be used in any query except for the example above, it's immutable and cleared within 10 days
Option1: Two tables with one to many relationship
Job Table: jobId, total_results, runDate
Job Result Table: jobId, user_id
Option2: Single table with longtext for results, comma delimitered user_id
Job Table: jobId, total_results, runDate, user_ids
Would it be better to use option1, or option2?