Skip to content
Advertisement

Join Two Non Related Tables

I have two tables Like A and B. Each have one column (ID) in ascending order. I want to join tables LIKE C Table. Datas are not statical but in A and B the row counts are always equal. I’ve tried join statements but couldn’t find out. Thanks for your help.

Advertisement

Answer

If you’re using a database that supports row_number() such as Oracle, postgresql, sql sql server:

Fiddle: http://sqlfiddle.com/#!15/5ac6b/1/0

If you’re using mysql you can mimic row_number using a variable:

Fiddle: http://sqlfiddle.com/#!9/5ac6b/2/0

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement