Answer the question
In order to leave comments, you need to log in
How to make SQL UNION if there is not full data in the tables?
I have never been a programmer, but fifteen years ago I once built a similar query ... I remember that I somehow applied UNION
fictitious fields like O AS FIELD
... And I also remember that I spent three weeks (or maybe more) on it. And now the brains are completely rusted and I can’t even figure out where to start. And you need something like this:
There is a "TAR" TABLE:
id1 | НАЗВАНИЕ_ТАРЫ
----+-------------------------
01 | Ящик
02 | Корзинка
03 | Грузовик
id2 | НАЗВАНИЕ_ГРУЗА
----+------------------------
01 | Огурцы
02 | Молоко
03 | Туалетная бумага
link1 | link2 | КОЛИЧЕСТВО
------+-----------+--------------------
01 | 01 | 15
01 | 02 | 2
02 | 01 | 4
02 | 03 | 2
03 | 01 | 100
03 | 02 | 60
03 | 03 | 500
НАЗВАНИЕ_ТАРЫ | НАЗВАНИЕ_ГРУЗА | КОЛИЧЕСТВО
---------------+--------------------+----------------
Ящик | Огурцы | 15
Ящик | Молоко | 2
Ящик | Туалетная бумага | 0
Корзинка | Огурцы | 4
Корзинка | Молоко | 0
Корзинка | Туалетная бумага | 2
Грузовик | Огурцы | 100
Грузовик | Молоко | 60
Грузовик | Туалетная бумага | 500
0
for the field КОЛИЧЕСТВО
in cases where the objects are not connected through ТАБЛИЦА СВЯЗЕЙ
. How?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question