Skip to content
Advertisement

MySQL- Create Duplicate Results in SELECT statement

I have a table like

ColumnA ColumnB ColumnC
ABC TextA 3
EFG TextB 1
EFG TextC 2

How do I write a SELECT statement that will return the # of rows for ColumnA and ColumnB based on the values of ColumnC

Expect results:

ColumnA ColumnB
ABC TextA
ABC TextA
ABC TextA
EFG TextB
EFG TextC
EFG TextC

Advertisement

Answer

You can use a recursive cte:

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