[英]Join DELETE in MySql? How to?
I have this: 我有这个:
$query="DELETE FROM classified, $sql_table WHERE classified.ad_id = '$id' AND classified.classified_id = $sql_table.classified_id AND classified.poster_password='$pass'";
I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE classified.ad_id = 'Bmw_M3_E46_Full_29920' AND classified.cla' at line 1
我收到此错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE classified.ad_id = 'Bmw_M3_E46_Full_29920' AND classified.cla' at line 1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE classified.ad_id = 'Bmw_M3_E46_Full_29920' AND classified.cla' at line 1
Any help? 有帮助吗?
As you can see the $sql_table is linked to the classifieds table with the fields classified_id
I need to JOIN DELETE somehow. 正如您所看到的,$ sql_table链接到带有
classified_id
字段的分类表,我需要以某种方式加入DELETE。
Basically classified table is the main table, then every category has its own tables with vehicle data. 基本上分类的表是主表,然后每个类别都有自己的车辆数据表。 classified table has a field called classified_id which is the same as the
分类表有一个名为classified_id的字段,它与
Here is the full query echoed: 这是回显的完整查询:
DELETE FROM classified, vehicles WHERE classified.ad_id = 'Bmw_M3_E46_410811305' AND classified.classified_id = vehicles.classified_id AND classified.poster_password='some_password'
Why isn't this working, Should it be so hard to delete from multiple tables? 为什么这不起作用,是否应该从多个表中删除这么难?
Thanks 谢谢
对于初学者,检查多表删除的语法您需要指定要从中删除的表
DELETE classified.*, vehicles.* FROM classified, vehicles
i just has detect something but didn't know its really working or not, try to put what you want to tied from two tables first like this: 我只是检测到了一些东西,但不知道它是否真正起作用,试着把你想要的东西从两个表中加入,如下所示:
DELETE FROM classified, vehicles WHERE classified.classified_id = vehicles.classified_id
AND classified.ad_id = 'Bmw_M3_E46_410811305'
AND classified.poster_password='some_password'
then only what exact value in the column you want to delete. 那么只有你要删除的列中的确切值。 please try n revert.
请尝试恢复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.