Php 加入Mysql语句问题
我有两个表单下拉列表,用于捕获两个ID,它们与名为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
节点的表中的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.也许完整地发布作业/考试问题比剥离相关细节更容易。