The following article mainly describes how to sort out the mysql table fields correctly. This article describes the specific steps of the operations in a single question and answer, which will give you a deeper understanding, the following describes the specific content of the article. I hope you will gain some benefits after browsing it. Table dz_tupian: mysql table field phidadress001wha
The following article mainly describes how to sort out the mysql table fields correctly. This article describes the specific steps of the operations in a single question and answer, which will give you a deeper understanding, the following describes the specific content of the article. I hope you will gain some benefits after browsing it. Table dz_tupian data mysql table field phid adress 001wha
The following article mainly describes how to sort out the mysql table fields correctly. This article describes the specific steps of the operations in a single question and answer, which will give you a deeper understanding, the following describes the specific content of the article. I hope you will gain some benefits after browsing it.
Table dz_tupian
Data in the current table
Mysql table field phid adress
- 001 whai
- 002 fdsadf
- 003 fdsfsdaf
- 002 dfewads
- 003 fwerasere
- 001 hfghgrtt
- ... ...
Expected results:
Field phid adress
- 001 whai hfghgrtt
- 002 fdsadf dfewads
- 003 fdsfsdaf fwerasere
There are many identical numbers in the phid to identify the duplicates first (there may be one or 60)
Then combine duplicate rows into one row ---- the second mysql table field adress with the same phid
Add it to the adress field of the newly integrated row
This is my idea. I don't know how to write code.
Question added: the second method is quite good. query in the mysql database and export the query results to get the expected results.
However, the adress type of the dz_tupian field is mediumtext. The maximum length of mediumtext is 16777215 characters.
Why are the exported query results incomplete? We can see that the adress value of the same phid is not completely added to the adress field.
Why?
The problem does not seem to be the limit on the number of characters in the adress field. However, if the number of characters in the same phid is large, the corresponding adress will be displayed if the number of characters in the last few are incomplete.
I have just checked that the adress field contains a maximum of 533 characters, but the adress type of the mysql table field is mediumtext. mediumtext has a maximum length of 16777215 characters. This is why it is incomplete. Why ????
Level-1 best answer:
The group_concat function has a size limit. The default value is 1024. You can modify the size according to your requirements. There are two methods:
1. Add the following in the mysql configuration file:
Group_concat_max_len = 102400 # maximum length you want
2. You can simply execute the statement:
- mysql> SET GLOBAL group_concat_max_len=102400;
- Query OK, 0 rows affected (0.01 sec)
For details, refer to the connection of reference materials.
Mysql can use the group_concat function. The following statement is passed in mysql 5.
- select phid,group_concat(adress order by adress separator " ") as adress
- from dz_tupian
- group by phid
The above content is an introduction to the integration of mysql table fields. I hope you will have some gains.