The problem of sql Multi-table query

1. If you use select * from APowerB without any conditions, the result will be displayed associated with tables an and b, but the result will be repeated many times
2, and select * from a join b, will not add any query conditions, and the result will be the same as 1. Ab is displayed side by side but the result is repeated many times
select * from a:
1 11
2 22
3 33
4 44
5 55
select * from b:
1 a
2 b
3 c
4 d
5 e
6 f
select * from a, B:
1 11 1a
2 22 1 a
3 33 1 a
4 44 1 a
5 55 1 a
1 11 2 b
2 22 2 b
3 33 2 b
4 44 2 b
5 55 2 b
1 11 3 c
2 22 3 c
3 33 3 c
4 44 3 c
5 55 3 c
1 11 4 d
2 22 4 4 4 d
1 11 5 e
2 22 5 e
3 33 5 e
4 44 5 e
5 55 5 e
1 11 6 f
2 22 6 f
3 33 6 f
4 44 6 f
5 55 6 f

Why is this? What is the order of multi-table queries?
what I actually want is
1 11 1a
2 22 2 b
3 33 3 c
4 44 4 d
5 55 5 e
null null 6 f

what should I do? Of course, it"s easy to add conditions directly with rightjoin. But what if there are matching conditions between an and b?

Mar.18,2021

directly select * from a, b will combine the rows of the two tables.

try full join ?


is a multi-table query without association conditions?


try using uniall all


select
*
from
a
join b on b.no=a.no

Why is this? I tested
if there are two tables TableA and TableB , the data are as follows:

  TableA       TableB
    1            6
    2            7
    3            8
    4            9
    5
  1. select * from TableA,TableB TableA table has 5 pieces of data, and TableB has 4 pieces of data. When querying, there will be 5X4=20 pieces of data

and the query data are all regular, similar to the arrangement and combination of mathematics, as follows:

  TableA   TableB
    1        6
    1        7
    1        8
    1        9
    2        6
    2        7
    2        8
    2        9
    3        6
    3        7
    3        8
    3        9
   ...      ...

and so on, it automatically assigns the fields of the TableA table to the table TableB and arranges them

2. It's the same as 1

Menu