Let’s consider two tables:
First:
Id Data
1 asd
2 buu
And Second:
UPD:
Id Data
10 ffu
11 fffuuu
10001 asd
I want to get a 4-column table looking like this:
Id1 Data1 Id2 Data2
1 asd 10 fuu
2 buu 11 fffuuu
-1 [any text] 10001 asd
(if the numbers of rows are not equal ,let’s use “-1” for the id)
How to do this?
I’m using sqlite3-3.7.3.
UPD2:
There is no matching criteria between tables,any random matching between them will be sufficient for me.
Assuming that the id columns are unique and not null, you can “zip” your tables by:
position of the row when the table is ordered by the unique id (as
polishchuk mentioned in his comment); and,
To demonstrate, I used two tables with differing row counts:
To obtain a more readable output, I then ran:
Then you can execute this SQL statement:
Which gives you:
This works “both ways”, for example, if you invert the two tables (foo and bar), you get: