我写了这个查询,但是在第15行(limit子句)给了我一个错误。我们有3张table,州,电子邮件和收件人。
CREATE PROCEDURE `inbox`(IN `page_size` INT,IN `page_number` INT)
BEGIN
set @curr = ( SELECT entered_accounts.username
FROM entered_accounts
WHERE entered_accounts.time = (SELECT Max(entered_accounts.time) FROM entered_accounts));
SET @tmp = page_number-1;
SET @offset = page_size * @tmp;
SELECT email.subject, email.body, email.time, state.readed, state.deleted
FROM email INNER JOIN reciever USING(email_id)
INNER JOIN state USING (email_id)
WHERE state.username=reciever.username AND LOWER(reciever.username)=LOWER(@curr) AND NOT reciever.username=email.username
ORDER BY email.time DESC
LIMIT @offset,page_size;
END
1条答案
按热度按时间x9ybnkn61#
mysql不支持中的用户变量
LIMIT
条款。相反,可以使用正则变量: