I have 2 tables (tmp1,tmp2). Every table contains unique (product)_id's only. I need to create a query to get a fixed and random number of ID's from table tmp2 for each ID from table tmp1. I've tried it with GROUP_CONCAT, but get's error:
SELECT p.products_id,
GROUP_CONCAT((SELECT tmp2.products_id FROM tmp2 tmp2 ORDER BY RAND() LIMIT 12))
FROM tmp1 tmp1
GROUP BY tmp1.products_id
LIMIT 1
"subquery returned more than one record"
That's the result I need.
example:
ID tmp1 | ID tmp2
1 | 103,204,867,547,354,514,541
2 | 542,245,876,542,681,248,428
Aucun commentaire:
Enregistrer un commentaire