A
A
Alina2020-05-12 20:01:43
MySQL
Alina, 2020-05-12 20:01:43

How to merge data in MYSQL table?

There is a table with a description of hotels, in some rows the hotel is the same, but the description is different, how to merge, keeping all the data to the maximum and delete the second row? One line has data in the cell, and the other does not, in the next line of this hotel, on the contrary, i.e. it is necessary to replace an empty field with data from another line, if they exist. That these are the same hotels is determined manually.
+----------------+-------------------------+------ ------+--------+
| id | name | description | year |
+----------------+-------------------------+------ ------+--------+
| 1 | Hotel | cool hotel | (empty) |
| again hotel 1 | Hotel Royal Palace (same Hotel) | (empty) |2017 |
+----------------+-------------------------+------ ------+--------+

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2020-05-13
@rivaufa

1. The table looks somehow very dull, in particular, it is not clear what is happening with the keys, why there are 2 records with id =
1 data.
It is more correct to use this table as raw data, and process it with some kind of logic in the script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question