为什么不在mysql 5.0中使用基于选择的删除
使用Mysql 5.0,这是可行的为什么不在mysql 5.0中使用基于选择的删除,mysql,sql,Mysql,Sql,使用Mysql 5.0,这是可行的 select * from jforum_topics t1 where topic_id in ( select topic_id from jforum_posts t2 where need_moderate=true ); 但事实并非如此 mysql> delete from jforum_topics t1 where top
select *
from jforum_topics t1
where topic_id in (
select topic_id
from jforum_posts t2
where need_moderate=true
);
但事实并非如此
mysql> delete from jforum_topics t1
where topic_id in (
select topic_id
from jforum_posts t2
where need_moderate=true
);
错误1064 42000:您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以获得在第1行的“从jforum中选择主题id中的where topic\u id”附近使用的正确语法
我认为它应该可以工作,否则我怎么做呢?在本例中,您可以在中使用,也可以不使用别名而存在t1:
或
或者需要别名两次:
在这种情况下,您可以在中使用,也可以不使用别名而存在t1:
或
或者需要别名两次:
你是说当从使用mysql外壳的终端运行时,查询不起作用,但它是从运行查询的其他机制中起作用的,比如phpMyAdmin或类似的jforum_topics t1中的delete t1……你是说当从使用mysql外壳的终端运行时,查询不起作用吗,但它确实来自于其他一些运行查询的机制,比如phpMyAdmin或类似的jforum_主题t1中的delete t1……不客气@PaulTaylor。从这个角度来看,MySQL很有趣。不客气@PaulTaylor。从这个角度来看,MySQL很有趣。
delete from jforum_topics
where topic_id in (
select topic_id
from jforum_posts t2
where need_moderate=true
);
delete from jforum_topics
where exists (
select 0
from jforum_posts t2
where need_moderate=true
and t2.topic_id = jforum_topics.topic_id
);
delete t1 from jforum_topics t1
where topic_id in (
select topic_id
from jforum_posts t2
where need_moderate=true
);