这个mySQL删除语句为什么出错啊?

龙上 发布于 2012/04/04 21:33
阅读 1K+
收藏 0

delete from blog b,comment c wher b.bid = c.bid AND b.bid = 9

就是想删除这两个表中字段bid = 9的所有数据

加载中
0
无名人士
无名人士
delete blog,comment from blog inner join comment blog.bid = comment.bid where blog.bid = 9
0
不是特别帅

elete from blog b,comment c wher b.bid = c.bid AND b.bid = 9

少了个e

0
龙上
龙上

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 'b,comment c wher b.bid = c.bid AND b.bid = 9354' at line 1

语句输入正确的

delete from blog b,comment c where b.bid = c.bid AND b.bid = 9354

0
龙上
龙上
#1064 - 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 'AS b,`comment` AS c where b.bid = c.bid AND b.bid = 9354' at line 1
0
leo108
leo108

何必呢……

用两条delete效率比你这个效率高多了……

0
_DeepBlue
_DeepBlue

分两条语句写 放在一个事物里

delete from blog where bid =9

delete from  comment   where bid =9

0
William
William
delete要指定删除哪个表吧? 是不是不能同时删除两个?
0
龙上
龙上

引用来自“William”的答案

delete要指定删除哪个表吧? 是不是不能同时删除两个?
应该是不能同时删除两个表的数据.我现在想用触发器.但是不知道怎么获取这个后面where id这个变量
0
龙上
龙上
用触发器吧这个搞定了..找半天资料才发现可以用old new两个关键字引用字段..
0
开源中国潜水
开源中国潜水

连接删除时要,指定删除那个表的内容:

delete b.* from blog b,comment c wher b.bid = c.bid AND b.bid = 9

返回顶部
顶部