我正在尝试在 mysql 中编写一个循环,以便一个查询的结果通知第二个。这是我当前的查询集:
select @post_date := from_unixtime(post_date)
from posts
where post_date > unix_timestamp('2012-10-20') and nsfw=1;
select @countofpost := count(@post_date);
while @countofpost > 0 DO
select count(*)
from live_sharedata.users
where joined between @post_date and (@post_date + 21600) and joined_site_id="RS";
set @countofpost = @countofpost -1;
end while;
我收到的错误是 [Err] 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 'while @countofpost > 0 DO 附近使用的正确语法。
任何想法将不胜感激。