select num1.n, 2 from num1, num2
expected output
table num1 table num2
2 2
3 3
4 4
5 5
6 6
7
8
9
10
actual output
num1, num2
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
10 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
10 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
10 2
CodePudding user response:
Number "2" is constant in your case.
You need to understand the correct relation between two tables.
After that you can build your select with JOIN to connect data from two tables correctly.
For example:
SELECT num1.n, num2.[field_from_table_num2]
FROM num1
JOIN num2 ON num2.[relation_field_or_key]= num1.[relation_field_or_key];
CodePudding user response:
you have define static column so that why you receive 2 in second column try following query
select num1.n As 'First_Table', num2.n As 'Second_Table'
from num1, num2