MySql using UNION (With an explanation)
First of all, you need to decompose the task: \n1) We need to use 1 Row and get all the necessary data in it, \n2) We need to convert the data to the form speci
First of all, you need to decompose the task: \n1) We need to use 1 Row and get all the necessary data in it, \n2) We need to convert the data to the form specified in the task, \n3) We need to implement a NULL check. \n\nWhy is the solution via UNION? \n\nBecause we need to achieve a result in which we have a selection from various "variations" of one table, for this we select the price for the goods from the store1 store, etc. recursively repeating the same thing, and then select the column with the name of the store (I made it as simple as possible, presented the magiz in the form of a column) and we check for NULL, I hope the code is explained more competently than I am)\n```\nSELECT\n    e.product_id, \n    "store1" AS store,\n    e.store1 AS price\nFROM Products e\nWHERE e.store1 IS NOT NULL\n\nUNION\n\nSELECT\n    e.product_id,\n    "store2" AS store,\n    e.store2 AS price\nFROM Products e\nWHERE e.store2 IS NOT NULL\n\nUNION\n\nSELECT\n    e.product_id, \n    "store3" AS store,\n    e.store3 AS price\nFROM Products e\nWHERE e.store3 IS NOT NULL\n;\n```
[]