SELECT Group_concat (Ut.id_card ORDER by Ut.id_card DESC SEPARATOR ', ') from ' Edu_user_train ' ut where ut.id in (614,615 ) Output: 500231199108181861,371324198450304515 usage Scenario: Returns a pure numeric mate in query example: SELECT u.name from ' edu_user ' u WHERE u.id_card in ( 500231199108181861,371324198450304515);
Select Group_concat (' "', Ut.id_card, '" ') from ' Edu_user_train ' ut where ut.id in (614,615); output: "500231199108133881", " 371325198706304515 "Usage Scenario: Returns the string (because there is an" X "in the ID) with the in query example: SELECT u.name from ' edu_user ' u WHERE u.id_card in (" 500231199108133881 "," 371325198706304515 ");
Select CONCAT (' "', Ut.id_card, '" ') from ' Edu_user_train ' ut where ut.id in (614,615); output: "500231199133133881" " 371325198706454515 "This is a relatively small case.
The difference between this section and the above is that when you add a group, you get a result and you wrap the line.
SELECT group_concat (U. Name ORDER by U. Name DESC SEPARATOR ",") as UserName from ' edu_user ' u WHERE u.id_card in (sele CT Ut.id_card from the ' Edu_user_train ' ut where ut.id in (614,615,939)); multiple data, subquery.
Welcome to add , this is my practice in the record, detailed usage and professional explanations please see the MySQL API.
Mysql Group_concat () function splicing string