dhope Posted September 4, 2010 Share Posted September 4, 2010 Hi, I was wondering if someone could point me in the right direction. I have built a small content management system for my website and I want to select all the pages from my database but only the last version. I would like to keep a previous version just in case I need to go back to it. My select statement is: SELECT page_name FROM pages WHERE user_id = $user_id AND page_visible = 1 AND page_deleted = 0 ORDER BY page_position ASC But this will print all my pages including all previous versions. I have added a date_updated updated field to my database, is there away to check which is the latest version and only select this page? Hope this makes sense. Thank you for any help Damian Quote Link to comment https://forums.phpfreaks.com/topic/212505-php-select/ Share on other sites More sharing options...
fenway Posted September 10, 2010 Share Posted September 10, 2010 IF the most recent 'date_updated' is the one one you want back, then a simple order by date desc limit 1 should do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/212505-php-select/#findComment-1109653 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.