在MySQL中,可以通过以下方式实现
SELECt id, length FROM vehicles WHERe id IN ( 117, 148, 126)+---------------+| id | length |+---------------+| 117 | 25 || 126 | 8 || 148 | 10 |+---------------+SELECt id,vehicle_ids FROM load_plan_configs WHERe load_plan_configs.id =42+---------------------+| id | vehicle_ids |+---------------------+| 42 | 117, 148, 126 |+---------------------+
现在要获取逗号分隔的vehicle_ids的长度,请使用以下查询
OutputSELECt length FROM vehicles, load_plan_configs WHERe load_plan_configs.id = 42 AND FIND_IN_SET( vehicles.id, load_plan_configs.vehicle_ids)+---------+| length |+---------+| 25 || 8 || 10 |+---------+
有关更多信息,请访问http://amitbrothers.blogspot.in/2014/03/mysql-split-comma-
separated-list-into.html



