新建line(线路表)和dot(点位表)表,查询某条线路上存在几个点
id | name |
1 | 点1 |
2 | 点2 |
3 | 点3 |
4 | dian4 |
id | name | dot_id_list |
1 | 线路1 | 1,2 |
2 | 线路2 | 2,3,4 |
sql语句:select a.*,b.* from line as a left join dot as b on FIND_IN_SET(b.id,a.dot_id_list) where a.id=2
id | name | dot_id_list | id1 | name |
2 | 线路2 | 2,3,4 | 2 | 点2 |
2 | 线路2 | 2,3,4 | 3 | 点3 |
2 | 线路2 | 2,3,4 | 4 | dian4 |