I have an SQL Query as below:
SELECT * FROM `mytable` WHERE 'myfield' = false
How can I select the latest x entries, for example the latest 10?
How would I need to format that in SQL?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unless you have some field in that table which represents time of insertion/update, you can’t do it. You need something like that in order to add an
ORDER BY... LIMIT 10clause. Another option would be to have a numeric field with anAUTO_INCREMENTproperty (maybe the primary key ?).The RDBMS is under no obligation to return the rows in a specific order (and it is wrong to rely on it), UNLESS you specify it explicitly.