SchweppesAle Posted March 31, 2009 Share Posted March 31, 2009 Hi, just having a little trouble with nested MySQL conditions the following will query all entries within a set category defined by the ID $query = "SELECT * FROM #__content WHERE (catid = '$cat1')"; which is great, however since this is a joomla database I wanted to make the application I'm designing won't pull content which has been unpublished so I tried expanding my condition to the following. $query = "SELECT * FROM #__content WHERE (catid = '$cat1' & publish_down < publish_up)"; Unfortunately, this seems to pull in all published content from every category. What would be the appropriate way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/151932-solved-conditions-within-mysql-query/ Share on other sites More sharing options...
premiso Posted March 31, 2009 Share Posted March 31, 2009 $query = "SELECT * FROM #__content WHERE (catid = '$cat1' AND publish_down < publish_up)"; Should work, given that the publish_down and publish_up is the correct way it should be. Quote Link to comment https://forums.phpfreaks.com/topic/151932-solved-conditions-within-mysql-query/#findComment-797838 Share on other sites More sharing options...
SchweppesAle Posted March 31, 2009 Author Share Posted March 31, 2009 hmmm...that was simple enough. It looks like it worked, but I think I mistook what the publish_down column was intended for(scheduling when to unpublish). Does anyone know how Joomla 1.5 differentiates between published/unpublished articles? Quote Link to comment https://forums.phpfreaks.com/topic/151932-solved-conditions-within-mysql-query/#findComment-797850 Share on other sites More sharing options...
lonewolf217 Posted March 31, 2009 Share Posted March 31, 2009 that may be a question for Joomla dev forums ? Quote Link to comment https://forums.phpfreaks.com/topic/151932-solved-conditions-within-mysql-query/#findComment-797851 Share on other sites More sharing options...
Maq Posted March 31, 2009 Share Posted March 31, 2009 hmmm...that was simple enough. It looks like it worked, but I think I mistook what the publish_down column was intended for(scheduling when to unpublish). Does anyone know how Joomla 1.5 differentiates between published/unpublished articles? Not sure, but you can find an unpublished and a published article and look in the database between what the differences are. Quote Link to comment https://forums.phpfreaks.com/topic/151932-solved-conditions-within-mysql-query/#findComment-797852 Share on other sites More sharing options...
SchweppesAle Posted March 31, 2009 Author Share Posted March 31, 2009 thanks a lot guys. It was the state column $query = "SELECT * FROM #__content WHERE (catid = '$cat1' AND state != 0)"; Quote Link to comment https://forums.phpfreaks.com/topic/151932-solved-conditions-within-mysql-query/#findComment-797877 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.