mercredi 28 juin 2023

Add a different random row from table A to each row in Table B

I have tow tables the one named A and the second named B, I want to add a a **different ** random row from table A to each row in Table B. There are no cummon fields between the tables.

I tried to do:

select idA,idB

from A,(select idB

        from B

        Order by dbms_random.random

        fetch first 1 row only)

But, the select in the 'from' executed only once. So, I got the same row from table B to all rows in table A.

Thanks.




Aucun commentaire:

Enregistrer un commentaire