开发者社区> 问答> 正文

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

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

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

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

展开
收起
爱吃鱼的程序员 2020-06-01 10:50:12 491 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    delete blog,comment from blog inner join comment blog.bid = comment.bid where blog.bid = 9######

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

    少了个e

    ######

    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

    ###### #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######

    何必呢……

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

    ######

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

    delete from blog where bid =9

    delete from  comment   where bid =9

    ######delete要指定删除哪个表吧? 是不是不能同时删除两个?######

    引用来自“William”的答案

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

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

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

    2020-06-01 10:50:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
One Box: 解读事务与分析一体化数据库 HybridDB for MySQL 立即下载
One Box:解读事务与分析一体化数据库HybridDB for MySQL 立即下载
如何支撑HTAP场景-HybridDB for MySQL系统架构和技术演进 立即下载

相关镜像