【发布时间】:2017-09-13 13:30:55
【问题描述】:
有一个 in 参数作为页面。我想要做的就是从中驱逐 1 并乘以 10。但它每次都会给我一个错误。
IF !a THEN
SELECT *
from entry
WHERE topic_foreign_id = (
select topic_id
from topic
where topic_name = topicName
)
ORDER BY entry_time ASC
LIMIT 10 OFFSET page;
ELSE
SELECT *
from entry
WHERE topic_foreign_id = (
select topic_id
from topic
where topic_name = topicName
)
ORDER BY entry_time ASC;
END IF
这行代码效果很好,但是当我想在第一个 SQL 查询中进行算术运算时,myAdmin 每次都会抛出错误。
SELECT *
from entry
WHERE topic_foreign_id = (
select topic_id
from topic
where topic_name = topicName
)
ORDER BY entry_time ASC
LIMIT 10 OFFSET 10 * ( page - 1); //throws error
【问题讨论】:
-
您忘记告诉我们实际的错误是什么。
-
@AlexK。查看第二个代码行的结尾:10 * ( page - 1) 是错误的原因。
标签: mysql sql stored-procedures