Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL - Join two tables, merging multiple matches onto one row

$
0
0

Hi all,

I'm pretty SQL green, so this is probably pretty basic, but...

Say I have two tables, with a common column of PRODUCTCODE

The left table, say TABLE1, has only one instance of each product code - every product is only in this table once

The right table, TABLE2, has each product code listed up to, say, 5 times, because TABLE 2 has a column FEATURES, and a product code can have up to 5 features.

Would there be any way to join these tables via PRODUCTCODE, and add a column to the results which contained a concatenated list of all values of the FEATURES column for any given product code? Or even a separate column for each feature per product code?

Hope this makes sense. If an example of the data would help, I can post one tomorrow, currently typing on a phone and it's not so easy to get looking right!

Cheers!


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>