Let's say I have two tables:
- TABLE A: User ID, many other cols. [PK is User ID]
- TABLE B: User ID, many other cols. [Many lines per User ID]
Is there any way I can go through each User ID in TABLE A and do in the SQL transformation something such as:
Declare TABLE C
for each User ID in TABLE A
- Append TABLE A.User ID, TABLE A.Name in TABLE C
- Select * from TABLE B where TABLE B.User Id = TABLE A.User Id
- Append TABLE B.User ID, TABLE B.Other Field in TABLE C
The idea would be to create a table in which you can find each line in TABLE A followed by every line for that same ID in TABLE B.
Sorry for the poor SQL terminology, as I am not very used to it.
Thank you so much in advance.
And this is your table B:
The code I suggested would give you the following table C:
If this is not the outcome you are looking for, please provide some example data for better understanding the problem.