Mysql 如何在SQL中的单个列中返回不同类型的值

Mysql 如何在SQL中的单个列中返回不同类型的值,mysql,Mysql,我的数据库是这样的 dict_name // dict_id // type apple // 100 // fruit pear // 101 // fruit car // 1000 // tool bus // 1001 // tool lisp // 22222 // other perl // 22223 // other SELECT d

我的数据库是这样的

dict_name  //  dict_id  //  type
    apple  //      100  // fruit
     pear  //      101  // fruit
      car  //     1000  //  tool
      bus  //     1001  //  tool
     lisp  //    22222  // other
     perl  //    22223  // other
SELECT dict_name WHERE dict_id=100 AND type=fruit
我可以得到一个这样的名字

dict_name  //  dict_id  //  type
    apple  //      100  // fruit
     pear  //      101  // fruit
      car  //     1000  //  tool
      bus  //     1001  //  tool
     lisp  //    22222  // other
     perl  //    22223  // other
SELECT dict_name WHERE dict_id=100 AND type=fruit
现在我想通过SQL中的dict_id获得不同类型的dict_名称


当我有dict\u id如100100022222时,它会返回苹果汽车lisp

SELECT GROUP_CONCAT(dict_name) WHERE dict_id=100 AND type=fruit
每种类型

你可以这样试试

SELECT GROUP_CONCAT(dict_name) FROM TABLE_NAME GROUP BY type

请再试一次

SELECT GROUP_CONCAT(DISTINCT(dict_name)) FROM TABLE_NAME WHERE dict_id IN(100,101, ..) GROUP BY type

但它的类型也是水果、工具和其他,当我有数据100100022222时。使用SELECT GROUP_CONCAT(dict_name)从表_name GROUP BY type中选择GROUP_CONCAT(dict_name),其中dict_id在(10010002222)GROUP BY type中,它将返回apple、car、lisp?它将返回大量dict_name,就像apple、apple、apple、:?它从单一类型返回dict_name,但现在的值不同,就像apple、pear一样。我想要返回apple、car、,属于不同类型的列表,非常感谢。是否可以在一条记录中返回多个dict_名称?