group_concat_max_len session variable to a large number to ensure that the dynamically created SQL query does not get truncated.@sql to NULL.GROUP_CONCAT to concatenate all the SELECT statements for each store column in the Products table, excluding the product_id column.SELECT statement that selects the product_id, the store name as store, and the store column as price only where the store column is not NULL.UNION to combine all the SELECT statements into one single query.@sql.erDiagram
Products {
int product_id PK
int store_name1
int store_name2
int store_namen
}