SQL inner join two tables with the same column names

后端 未结 2 1007
余生分开走
余生分开走 2021-02-13 11:03

I have two tables with a variable amount of columns. (I don\'t know how many columns or what there names will be) for example Table A and Table B.

TableA:



        
相关标签:
2条回答
  • 2021-02-13 11:12

    Your result set (given your query) should have all of the TableA columns followed by all the TableB colums, so when you get to the second ID colum, you know you're into the TableB data.

    That said, it is would seem odd to me that you're querying all the data out of two tables about which you know functionally nothing...

    0 讨论(0)
  • 2021-02-13 11:25

    This is admittedly a hack solution, but this:

    SELECT TableA.*, "#", TableB.* 
    FROM TableA INNER JOIN TableB ON TableA.B_ID= TableB.id;
    

    Would produce a list of results which would be divided in two blocks, left and right of the # column.

    0 讨论(0)
提交回复
热议问题