Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能告诉我为什么我对组功能的使用无效以及如何阻止它?
SELECT Name, Message FROM flux_chat_messages WHERE id >= ( MAX( id ) -5 ) ORDER BY id ASC
您不能MAX()在WHERE. 所以把它包装在一个子查询中,比如:
MAX()
WHERE
SELECT Name, Message FROM flux_chat_messages WHERE id >= (SELECT MAX( id ) - 5 FROM flux_chat_messages) ORDER BY id ASC
也可能你可以有
SELECT Name, Message FROM flux_chat_messages ORDER BY id DESC LIMIT 5
并反转程序中的结果(或为此使用另一个子查询)