MySQL Forums
Forum List  »  MySQL Query Browser

help with query - how to limit SELECT to 20
Posted by: David Bahar
Date: October 19, 2011 10:28AM

SELECT * FROM logbooks WHERE person_id = #{person_id.to_s} AND logbook_type_id = 2 ORDER BY created_at DESC LIMIT 25 UNION ALL SELECT * FROM logbooks WHERE person_id = #{person_id.to_s} AND logbook_type_id = 1 ORDER BY created_at DESC

Seems mysql won't let me put a "order by" on the first select. is there a more efficient way for me to write this query that will let me limit the results to the newest 20 "created_at" records?

Thanks in advance!

Options: ReplyQuote


Subject
Written By
Posted
help with query - how to limit SELECT to 20
October 19, 2011 10:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.