mysql从连接表中删除记录

时间:2012-01-07 23:47:43

标签: javascript mysql join

我无法从连接到我正在选择删除的mysql表中删除记录。

我通过选择一个复选框并单击我网站上javascript表界面上的提交按钮来执行以下删除语句,该界面使用jos_fsdspremade.id作为其自动增量密钥和典型的删除ID。

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" />'

但没有从jos_fsdscart中删除任何内容。日志如下:

  

属性'id'的替换值为'61'

     

executeQuery [start:0,limit:0]'query1'()

     

查询代码: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表中删除记录:

如果有帮助,这是我在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`

1 个答案:

答案 0 :(得分:0)

我非常怀疑你是否有一个mysql表,其构造方式是'id'设置为varchar,它将接受类似("jos_fsdspremade.id" multiple="y" )的内容。

您需要从表单中获取ID(其中显示的ID是可选的)并将其传递给查询:

WHERE jos_fsdspremade.id = 1

或者如果你想做多重ID:

WHERE jos_fsdspremade.id in (1, 2, 3)