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 –