0
有一个in参数为页面。我想要做的就是从中排除1并乘以10,但每次都会给我一个错误。我无法在存储过程中进行aritmetic操作mysql
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的aritmetic操作抛出一个错误每次。
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)是错误原因。 –
请参阅https://stackoverflow.com/questions/300697/using-variables-as-offset-in-select-statments-inside-mysqls-stored-functions –