Asil Eris
Asil Eris

Reputation: 31

t-sql multiplying two tables

I have 2 tables

Plant            config         
------         --------

TRZ1            KS

MAS1            MT

I would like to have below table with 2 columns

RESULT
------
TRZ1  KS

TRZ1  MT

MAS1  KS

MAS1   MT

Thanks for the help

Upvotes: 0

Views: 420

Answers (3)

Markomafs
Markomafs

Reputation: 546

Use can use CROSS JOIN:

SELECT P.NAME, C.NAME FROM Plant AS P CROSS JOIN Config AS C

Upvotes: 0

Taryn
Taryn

Reputation: 247640

It is not clear if you want this in the same column, if so then you can concatenate the values using:

select p.col1 + ' ' + c.col1 as result
from plant p
outer apply config c

See SQL Fiddle with Demo

If not, then you can use:

select p.col1 plant, c.col1 config
from plant p
outer apply config c

See SQL Fiddle with Demo

Upvotes: 2

heximal
heximal

Reputation: 10517

the shortest way:

   select * from plant, config

Upvotes: 0

Related Questions