sql merge tables side-by-side with nothing in common

sql

Solution

You can do this by creating a key, which is the row number, and joining on it.

Most dialects of SQL support the `row_number()` function. Here is an approach using it:

select gu.id, gu.name, gi.id, gi.name
from (select g.*, row_number() over (order by id) as seqnum
      from guys g
     ) gu full outer join
     (select g.*, row_number() over (order by id) as seqnum
      from girls g
     ) gi
     on gu.seqnum = gi.seqnum;

Problem

I'm looking for an sql answer on how to merge two tables without anything in common. ``` So let's say you have these two tables without anything in common: Guys Girls id name id name --- ------ ---- ------ 1 abraham 5 sarah 2 isaak 6 rachel 3 jacob 7 rebeka 8 leah and you want to merge them side-by-side like this: Couples id name id name --- ------ --- ------ 1 abraham 5 sarah 2 isaak 6 rachel 3 jacob 7 rebeka 8 leah How can this be done? ``` I'm looking for an sql answer on how to merge two tables without anything in common.

Original source