title: select * from table where id in (select group_concat(id) from table ) How to implement batch and new data using the group_concat function IN IN()?
body: <p><a href="https://i.stack.imgur.com/ZBaAE.png" rel="nofollow noreferrer">enter image description here</a>SELECT * FROM <code>user</code> WHERE id IN (select group_concat(id) from <code>user</code> GROUP BY sex) ;  </p>
  
  <p>I want the following result </p>
  
  <pre><code>UPDATE `user` SET average_age =  (SELECT AVG(score) FROM `score` WHERE id IN (select user_id from `score`))  
  </code></pre>
  
  <p>SELECT AVG(score) FROM <code>user</code> WHERE id IN (1,2,3) ;
  SELECT AVG(score) FROM <code>user</code> WHERE id IN (2,5) ;
  ......</p>
  
  <p>How to implement batch and new data using the group_concat function IN IN()?</p>
  
  <p>data :</p>
  
  <pre><code>  SET NAMES utf8mb4;
  SET FOREIGN_KEY_CHECKS = 0;
  
  -- ----------------------------
  -- Table structure for user
  -- ----------------------------
  DROP TABLE IF EXISTS `user`;
  CREATE TABLE `user`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `sex` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `age` int(11) NULL DEFAULT NULL,
    `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `score` int(11) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
  
  -- ----------------------------
  -- Records of user
  -- ----------------------------
  INSERT INTO `user` VALUES (1, 'man', 21, 'Tom', 300);
  INSERT INTO `user` VALUES (2, 'man', 23, 'Jerry', 350);
  INSERT INTO `user` VALUES (3, 'woman', 18, 'Mary', 400);
  INSERT INTO `user` VALUES (4, 'woman', 12, 'Lily', 450);
  INSERT INTO `user` VALUES (5, 'woman', 16, 'Jasmine', 320);
  INSERT INTO `user` VALUES (6, 'woman', 16, 'Jasmine', 420);
  INSERT INTO `user` VALUES (7, 'woman', 18, 'Violet', 500);
  INSERT INTO `user` VALUES (8, 'woman', 18, 'Violet', 580);
  INSERT INTO `user` VALUES (9, 'woman', 20, 'Sophia', 520);
  INSERT INTO `user` VALUES (10, 'man', 22, 'Charlotte', 450);
  INSERT INTO `user` VALUES (11, 'man', 18, 'Jackson', 400);
  
  SET FOREIGN_KEY_CHECKS = 1;
  
  DROP TABLE IF EXISTS `score`;
  CREATE TABLE `score`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `user_id` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
    `average_score` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
  
  -- ----------------------------
  -- Records of score
  -- ----------------------------
  INSERT INTO `score` VALUES (1, '1,2,3', NULL);
  INSERT INTO `score` VALUES (2, '2,5', NULL);
  INSERT INTO `score` VALUES (3, '1,3,4,5', NULL);
  INSERT INTO `score` VALUES (4, '2,3,6,8,11', NULL);
  INSERT INTO `score` VALUES (5, '2,3,6', NULL);
  INSERT INTO `score` VALUES (6, '2,3,4,5,6,7', NULL);
  INSERT INTO `score` VALUES (7, '2,3,4,5,6,7', NULL);
  INSERT INTO `score` VALUES (8, '3,4,5,9,10', NULL);
  INSERT INTO `score` VALUES (9, '2', NULL);
  INSERT INTO `score` VALUES (10, '3,5,8,9,10', NULL);
  INSERT INTO `score` VALUES (11, '3,5,8,9,10', NULL);
  
  SET FOREIGN_KEY_CHECKS = 1;
  </code></pre>