I am having trouble figuring out how to execut the following SQL query. Say for example I have the following 2 databases.
Db1
Col_1 Col_2
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 j
9 h
10 i
Db2
Col_1 Col_2
1 j
2 a
3 d
4 e
5 c
6 b
7 f
8 g
9 h
10 i
Then I have the following 2 Select queries:
SELECT Db1.Col_1 AS 'test1' FROM Db1, Db2 WHERE DB2.Col_2=DB1.Col_1 AND DB2.Col_1 < 5
SELECT Db1.Col_1 AS 'test2' FROM Db1, Db2 WHERE DB2.Col_2=DB1.Col_1 AND DB2.Col_1 > 5
I then want the resulting query to be returned in separate columns, to look something along these lines:
test1 test2
a h
c i
d
e
Is this possible to do somehow using joins that just cannot figure out? Or is it simpler? Or even more complicated?
Any help is greatly appreciated