aftab_jii Posted April 15, 2010 Share Posted April 15, 2010 i want to show last two posts where posts with category About Me and Our Services are skipped. i managed to do it with the query below, but it only returns one post if the next post has category About Me or Our Services. i want the sql to skip the two categories and show two posts $sql = "SELECT article_id FROM articles WHERE is_published=1 AND category <> 'About Me' AND category <> 'Our Services' ORDER BY date_published DESC LIMIT 0,2"; $sql_result = mysql_query($sql) or die('Could not run query; ' . mysql_error()); i tried with SKIP (category = 'About Me') but got an error Quote Link to comment https://forums.phpfreaks.com/topic/198654-sql/ Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 I don't know what you mean "are skipped". Can you lay out an example? Also, you should try using Google rather than making stuff up like SKIP(). Well, at least, I can't find anything on it. Quote Link to comment https://forums.phpfreaks.com/topic/198654-sql/#findComment-1042485 Share on other sites More sharing options...
andrewgauger Posted April 15, 2010 Share Posted April 15, 2010 $sql = "SELECT article_id FROM articles WHERE is_published=1 AND category NOT IN('About Me', 'Our Services') ORDER BY date_published DESC LIMIT 0,2"; Quote Link to comment https://forums.phpfreaks.com/topic/198654-sql/#findComment-1042491 Share on other sites More sharing options...
aftab_jii Posted April 15, 2010 Author Share Posted April 15, 2010 that worked thanks Quote Link to comment https://forums.phpfreaks.com/topic/198654-sql/#findComment-1042497 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.