I have such query:
SELECT id, forum_theme, owner, enter_time, main_topic
FROM forum_message
WHERE main_topic IN (1,2,3)
ORDER BY enter_time DESC
LIMIT 3
Array is changing, and I'm adding it in java, so LIMIT equals size of array. Problem is - I need every record unique by main_topic, so each element of array must have only one record, but instead I'm having 1, 2, 2 topic records, etc.
How can I change my query to maki it possible?