执行下面语句
SELECT GROUP_CONCAT(cast(`id` as char(10)) SEPARATOR ',') from table_name
因为通常id是int类型,直接执行GROUP_CONCAT(id SEPARATOR ','),返回的将是BLOB类型,所以通过cast函数转换字符类型
得到的结果是类似
20215,20277,20001,20004,20005,20006,20007,20008,20009,20010,20011,20013,20016,20017,20018,20019,20020,20021,20022,20023,20025,20026,20027,20029,20030,20031,20032,20034,20036,20039,20042,20043,20044,20047,20049,20052,20053,20055,20056,20210,20062,20063,20064,20066,20067,20068,20070,20071,20073,20077,20079,20080,20081,20088,20092,20099,20100,20102,20103,20104,20107,20108,20113,20114,20115,20116,20117,20119,20121,20123,20124,20125,20129,20130,20132,20134,20146,20152,20157,20161,20162,20165,20167,20168,20171,20172,20175,20178,20181,20183,20185,20188,20189,20190,20192,20191,20193,20194,20195,20196,20198,20199,20200,20202,20204,20205,20206,20207,20208,20209,20211,20212,20213,20214,20216,20218,20219,20220,20221,20222,20224,20225,20226,20229,20231,20233,20237,20238,20240,20241,20242,20243,20245,20247,20248,20249,20250,20251,20253,20257,20258,20259,20260,20261,20262,20265,20266,20267,20268,20269,20271,20272,20273,20274,20275,20276,20279,20281,20284,20286,20288,20289
这样的所有id用逗号串起来的整个字符串