从不同的表中选择3列到一列

时间:2022-04-10 20:19:37

I'd like to combine 3 different columns witch are contains company names but stored in different groups!

我想结合3个不同的列,包含公司名称但存储在不同的组中!

Like:

  1. Company_inland
  2. Company_import
  3. Company_import_group

Each category comes from a temporary table, and after I have to combine all the fields into one column I'll tried the following lines but I got 0-values for all.

每个类别都来自一个临时表,在我必须将所有字段组合成一列之后,我将尝试以下行,但我得到了0值。

select (hamburger_belfold.Szallito_nev +' '+ hamburger_import.szallito_nev +' '+ hamburger_import_group.szallito_nev ) as 'Szállitó' 
from hamburger_belfold,hamburger_import,hamburger_import_group;

and I want something like this:

我想要这样的东西:

Combine Table |
Company 1     |from table 1
company 2     |from table 1
company 3     |from table 1

company 4     |from table 2
company 5     |from table 2
company 6     |from table 2

company 7     |from table 3
company 8     |from table 3
company 9     |from table 2

1 个解决方案

#1


0  

If you want to have it in one column, instead of CONCAT use UNION:

如果您想将它放在一列中,而不是使用CONCAT,请使用UNION:

SELECT Szallito_nev FROM hamburger_belfold
UNION
SELECT szallito_nev FROM hamburger_import
UNION
SELECT szallito_nev FROM hamburger_import_group;

#1


0  

If you want to have it in one column, instead of CONCAT use UNION:

如果您想将它放在一列中,而不是使用CONCAT,请使用UNION:

SELECT Szallito_nev FROM hamburger_belfold
UNION
SELECT szallito_nev FROM hamburger_import
UNION
SELECT szallito_nev FROM hamburger_import_group;