如何从 mysql 的哪一列中获取数据,其中包含逗号运算符的数据?
how to fetch data from mysql which column have data with comma operator?
任务Table
id assign_to task
1 1,2,4 Development
2 2,5,3 Testing
员工Table
id Name
1 Dhawan
2 Sachin
3 Dhoni
4 Virat
5 Rohit
这里我试图从员工 table 获取所有员工姓名并进入任务 table 的 assign_to 字段。所以我的输出会低于
id assign_to task
1 Dhawan, Sachin,Virat Development
2 Virat, Rohit, Dhoni Testing
下面是我写的查询。谁能告诉我这个
的查询是什么
select t.*, from task t inner join employee e on e.id in (t.assign_to)
已将您的查询更新为:
select t.*, from task t inner join
employee e on FIND_IN_SET(e.id, t.assign_to) > 0
GROUP BY e.id
请试试这个
select task.id,
(select group_concat(employee.name,',')
from employee employee
where find_in_set(employee.id, task.assign_to)> 0 ) as emp ,
task.task
from task task;
任务Table
id assign_to task
1 1,2,4 Development
2 2,5,3 Testing
员工Table
id Name
1 Dhawan
2 Sachin
3 Dhoni
4 Virat
5 Rohit
这里我试图从员工 table 获取所有员工姓名并进入任务 table 的 assign_to 字段。所以我的输出会低于
id assign_to task
1 Dhawan, Sachin,Virat Development
2 Virat, Rohit, Dhoni Testing
下面是我写的查询。谁能告诉我这个
的查询是什么select t.*, from task t inner join employee e on e.id in (t.assign_to)
已将您的查询更新为:
select t.*, from task t inner join
employee e on FIND_IN_SET(e.id, t.assign_to) > 0
GROUP BY e.id
请试试这个
select task.id,
(select group_concat(employee.name,',')
from employee employee
where find_in_set(employee.id, task.assign_to)> 0 ) as emp ,
task.task
from task task;