0

i should migrate multiple columns of text into one column (in another database). Now i know that it sounds complicated, but i will try my best to explain it. There is a table in mysql database called "products_desriptions". In that table we have columns like: descriptionDosage, descriptionAction, descriptionIndications and so on. What i want to do is to merge these columns into one column called "productDescription". Here is an example of what i have done:

SELECT 
   CONCAT_WS('\ntest', action, Indications, staff, dosage) AS productDescription)
FROM 
   products_descriptions
WHERE 
   product_id = 123

So the the columns are being merged successfully. The problem is that for each column there is a title in the frontpage, which is not being stored into the respective column. For example in the "dosage" column we have text like: "2xday, 14xweek" and so on. And on the frontpage what you can see is something like: "DOSAGE: 2xday, 14xweek" and so on. So for each column there is a hard codded title like this one, which i don't know how to get. I mean what i want to do is: to merge columns and respectively for each column i want a title to the respective text. I am working on php, so maybe it is not possible to be done only by mysql. Maybe i have to do it with php, but has anyone got any idea what exactly should i do?

1 Answers1

1

You can use concat function.

SELECT 
   CONCAT('\ntest', action, '\nIndictions:', Indications,'\nstaff:', staff,'\ndosage:', dosage) AS productDescription
FROM 
   products_descriptions
WHERE 
   product_id = 123
Atal Prateek
  • 541
  • 3
  • 7