在 MySql 中加入 DELETE?如何? [英] Join DELETE in MySql? How to?

查看:29
本文介绍了在 MySql 中加入 DELETE?如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个:

$query="DELETE FROM classified, $sql_table WHERE classified.ad_id = '$id' AND classified.classified_id = $sql_table.classified_id AND classified.poster_password='$pass'";

我收到此错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 1 行的WHERElocated.ad_id = 'Bmw_M3_E46_Full_29920' AND Classification.cla' 附近使用的正确语法

有什么帮助吗?

如您所见,$sql_table 链接到带有 classified_id 字段的分类表我需要以某种方式加入删除.

As you can see the $sql_table is linked to the classifieds table with the fields classified_id I need to JOIN DELETE somehow.

基本分类表是主表,然后每个类别都有自己的车辆数据表.分类表有一个称为分类 ID 的字段,它与

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

这是回显的完整查询:

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?

谢谢

推荐答案

DELETE a, b FROM
classified as a, $sql_table as b
WHERE
classified.ad_id = '$id' 
AND classified.classified_id = $sql_table.classified_id 
AND classified.poster_password='$pass'";

来源:来源

这篇关于在 MySql 中加入 DELETE?如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆