Mysql combines multiple data entries corresponding to the same ID.
This example describes how to merge multiple data entries with the same ID in mysql. We will share this with you for your reference. The details are as follows:
For example:
CREATE TABLE `c_classuser_tab` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `Classid` int(11) DEFAULT NULL, `Username` varchar(100) DEFAULT NULL, `studentid` varchar(100) DEFAULT NULL, `College` varchar(100) DEFAULT NULL, `Department` varchar(100) DEFAULT NULL, `Email` varchar(100) DEFAULT NULL, `Phone` varchar(100) DEFAULT NULL, `Status` int(11) DEFAULT NULL, `Remark1` varchar(100) DEFAULT NULL, `Remark2` varchar(100) DEFAULT NULL, `Remark3` varchar(100) DEFAULT NULL, `activateTime` datetime DEFAULT NULL, `joinTime` datetime DEFAULT NULL, `userID` int(11) DEFAULT NULL, `userType` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `C_classuser_tab_index` (`studentid`), KEY `idx_classuser_complex` (`Classid`,`userID`)) ENGINE=MyISAM AUTO_INCREMENT=31091 DEFAULT CHARSET=utf8;
Teachers with the same ID have multiple substitute classes and merge them,
Instructor substitute Class
Class 12, Class 2
Copy codeThe Code is as follows: select Username, GROUP_CONCAT (Remark1, '') as classes from c_classuser_tab where userID = * and userType = *