Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 要使用';在';另一个表的声明';s列值_Mysql - Fatal编程技术网

Mysql 要使用';在';另一个表的声明';s列值

Mysql 要使用';在';另一个表的声明';s列值,mysql,Mysql,我有以下表格结构: 物主 行动清单 行动 ActionList.Actions的格式如下: ActionId1, ActionId2, ActionId3, ActionId4, ... ActionIdN 我正在尝试执行此查询: select o.*, a.Name from Owner as o join ActionList as al on al.ActionListId = o.ActionListId join Action as a on a.ActionId

我有以下表格结构:

物主 行动清单 行动 ActionList.Actions的格式如下:

ActionId1, ActionId2, ActionId3, ActionId4, ... ActionIdN
我正在尝试执行此查询:

select 
    o.*,
    a.Name
from Owner as o
join ActionList as al on al.ActionListId = o.ActionListId
join Action as a on a.ActionId in (al.Actions)
where o.OwnerId = 1;
但我正在找回一张唱片。为什么第二个连接没有成功连接整个数组,而只连接第一个元素?有没有一种方法可以通过一个查询获取ActionList中的所有操作?

试试下面的方法

SELECT O.*,A.Name
FROM Owner AS O
     LEFT JOIN ActionList AS AL ON 
               AL.ActionListId = O.ActionListId
     LEFT JOIN Action AS A ON 
               A.ACtionID IN (SELECT ACTIONS FROM ACTIONList)
WGERE O.OwnerId = 1;

嗯,我尝试过这样做,假设“从动作中选择动作”是“从动作列表中选择动作”,其中ActionList.ActionListId=AL.ActionListId,但我仍然只得到1条记录。您的动作列表。动作在同一列中包含多个ActionId1??意味着在一个单元格中我们可以有更多的thn 1 ActionId,对吗??像ActionId1,ActionId2,ActionId3
ActionId1, ActionId2, ActionId3, ActionId4, ... ActionIdN
select 
    o.*,
    a.Name
from Owner as o
join ActionList as al on al.ActionListId = o.ActionListId
join Action as a on a.ActionId in (al.Actions)
where o.OwnerId = 1;
SELECT O.*,A.Name
FROM Owner AS O
     LEFT JOIN ActionList AS AL ON 
               AL.ActionListId = O.ActionListId
     LEFT JOIN Action AS A ON 
               A.ACtionID IN (SELECT ACTIONS FROM ACTIONList)
WGERE O.OwnerId = 1;