Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.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
Php 加入Mysql语句问题_Php_Mysql - Fatal编程技术网

Php 加入Mysql语句问题

Php 加入Mysql语句问题,php,mysql,Php,Mysql,我有两个表单下拉列表,用于捕获两个ID,它们与名为节点的表中的PK相关 我想从另一个名为relationships的表中删除这两个节点 所以在我收集了两个节点ID之后,我试图删除与另一个节点有关系的一个节点 在我的关系中,id和goingto都是节点,但是只有id是FK,而另一个不是 那么,如果它是在一段关系中,我该如何删除它呢 这是我的尝试 $goingto = $_POST['id_one']; //get from form both from id in nodes $id = $_PO

我有两个表单下拉列表,用于捕获两个ID,它们与名为
节点的表中的PK相关

我想从另一个名为
relationships
的表中删除这两个节点

所以在我收集了两个节点ID之后,我试图删除与另一个节点有关系的一个节点

在我的关系中,
id
goingto
都是节点,但是只有
id
是FK,而另一个不是

那么,如果它是在一段关系中,我该如何删除它呢

这是我的尝试

$goingto = $_POST['id_one']; //get from form both from id in nodes
$id = $_POST['idtwo']; //get from form both from id in nodes

mysql> DELETE from relationships where $id = $goingto;
以下是我的表格结构:

nodes                 relationships                      
-----                 -------------
id int(11),           id int(11),
name varchar(35),     goingto int(11), //this is the destinationnode from the id relation 
color varchar(7),     data varchar(0) null
type varchar (12),    Foreign key (id) references nodes(id)
Primary key (id)       

engine = innodb    

你认为这就是你的意思吗:


从id=$id和goingto=$goingto的关系中删除

是的,我就是这个意思。
id\u one
id\u two
是否保证通过
关系表相互关联?2.如果是这样的话,我们是否知道它是
id\u-one
转到
id\u-two
,还是
id\u-two
转到
id\u-one
?或者会有两个关系记录-即每个方向一个?3.是否要删除
节点
本身(以及这些节点的所有关联
关系
),还是仅删除它们之间存在的
关系
?4.也许完整地发布作业/考试问题比剥离相关细节更容易。