Skip to content
Advertisement

SQL How to select from multiple values in joined table

I have two tables A and B joined with a common id field. Table A has single entries per id. Table B has multiple entries per id. Table B has two columns “name” and “customertype”. I want to be able to SELECT columns from A and B but I want to show the column “name” from Table B three times: once for each separate match of customertype.

Example:

2 Tables

I want to be able to SELECT and display:

How do I do this? I am a novice SQL user! Thanks in advance for advice.

Advertisement

Answer

You can use conditional aggregation:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement