[英]mysql delete record from joined table
i am having trouble deleting a record from a mysql table that is joined to the one i'm selecting the delete from. 我在从mysql表中删除一条记录时遇到了麻烦,该表与我选择从中删除的记录联接在一起。
I execute the following delete statement by selecting a checkbox and clicking a submit button on a javascript table interface on my website that uses jos_fsdspremade.id as its autoincrement key and typical delete id. 我通过选择一个复选框并单击我的网站上使用jos_fsdspremade.id作为其自动增量键和典型删除ID的javascript表界面上的Submit按钮来执行以下delete语句。
DELETE jos_fsdscart.*
FROM jos_fsdscart
LEFT JOIN jos_fsdspremade ON jos_fsdscart.mfd = jos_fsdspremade.item_number
WHERE jos_fsdspremade.id = ( '<input name="jos_fsdspremade.id" multiple="y" />' ) AND jos_fsdscart.id4 = '<code type="user" />'
but nothing is deleted from jos_fsdscart . 但不会从jos_fsdscart中删除任何内容 。 the log is as follows:
日志如下:
Replacement value for attribute 'id' is '61'
属性“ id”的替换值为“ 61”
executeQuery[ start: 0, limit: 0 ] 'query1' ( )
executeQuery [开始:0,限制:0]'query1'()
Query Code: DELETE jos_fsdscart.* FROM jos_fsdscart LEFT JOIN jos_fsdspremade ON jos_fsdscart.mfd = jos_fsdspremade.item_number WHERE jos_fsdspremade.id = ( '' ) AND jos_fsdscart.id4 = ''
查询代码:删除jos_fsdscart。
As you can see, I am trying to delete a record from the jos_fsdscart table based upon a selection from a joined table: 如您所见,我正在尝试根据联接表中的选择从jos_fsdscart表中删除一条记录:
if it helps, here is the mysql query that i am selecting from in the javascript interface: 如果有帮助,这是我在javascript界面中选择的mysql查询:
SELECT
`<output name="jos_fsdspremade.owner_id" hidden="y" />`,
`<output name="jos_fsdspremade.id" title="FSDS" width="70" text="view" type="next" query="24" task="showResults" linktype="open" sizex="980" sizey="730" />`,
`<output name="jos_fsdspremade.item_number" title=".pdf" width="70" text="SAVE" type="link" url="/menumanager/images/pdf/%s.pdf" />` ,
`<output name="jos_fsdspremade.pic" title="Image" type="link" linktype="img" url="/menumanager/images/preman/%s" sizex="30" sizey="30" width="65" />`,
`<output name="jos_fsdspremade.title" title="Product Name" width="300" filter="y" />`,
`<output name="jos_fsdspremade.brand" title="Brand" width="300" filter="y" />`,
`<output name="jos_fsdspremade.manufacturer" title="Distributor" width="200" filter="y"/>`,
`<output name="jos_fsdspremade.product_type" width="200" filter="y"/>`
FROM jos_fsdspremade, jos_fsdscart
WHERE `published`=1 AND jos_fsdscart.mfd = jos_fsdspremade.item_number AND `id4` = '<code type="user" />'
ORDER BY `title`
I highly doubt you have a mysql table constructed in such a way that 'id' is set to a varchar which will accept something like ("jos_fsdspremade.id" multiple="y" )
. 我非常怀疑您是否以这样的方式构造了一个mysql表,即将'id'设置为一个varchar,它将接受类似
("jos_fsdspremade.id" multiple="y" )
。
You need to get the ids from the form (where it appears id is selectable) and pass them to the query: 您需要从表单中获取ID(在其中ID可以选择的地方)并将其传递给查询:
WHERE jos_fsdspremade.id = 1
Or if you want to do multipe ids: 或者,如果您想做多ID:
WHERE jos_fsdspremade.id in (1, 2, 3)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.