草庐IT

forDepts

全部标签

php - mysql FIND_IN_SET() 用分号代替逗号

我有一个看起来像这样的数据库集Table:Notesnid|forDepts--------------1|1;2;42|4;5Table:Positionsid|name--------------1|Executive2|CorpAdmin3|Sales4|Art5|Marketing如果forDepts中的数据由逗号分隔,则此查询将有效SELECTa.nid,GROUP_CONCAT(b.nameORDERBYb.id)DepartmentNameFROMNotesaINNERJOINPositionsbONFIND_IN_SET(b.id,a.forDepts)>0GROUPB