sohaibshaheen Posted August 29, 2010 Share Posted August 29, 2010 Usually I prefer to search the internet instead of Posting it somewhere! But This time I am stuck ... .... I got no other option when such simple statement isn't giving expected response! To the point.. What I want to do is to get the posts from table "user_post" where 1. (postby = current user && postfor=NULL) 2. OR (postfor = Current User) to display on users wall... The code looks like this.. mysql_query(" SELECT * FROM user_post WHERE ( (postby='$cur_user_id' && postfor=NULL) || (postfor='$cur_user_id') ) ORDER BY postdate DESC LIMIT $num_posts") or die(mysql_error()); But all it gives is the postfor= current user Somebody plz take me out of this pit!!! Quote Link to comment https://forums.phpfreaks.com/topic/211981-struggling-with-where-clause/ Share on other sites More sharing options...
DavidAM Posted August 29, 2010 Share Posted August 29, 2010 Nothing is ever equal to NULL, not even another NULL. You have to use 'IS NULL' mysql_query(" SELECT * FROM user_post WHERE ( (postby='$cur_user_id' && postfor IS NULL) || (postfor='$cur_user_id') ) ORDER BY postdate DESC LIMIT $num_posts") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/211981-struggling-with-where-clause/#findComment-1104810 Share on other sites More sharing options...
sohaibshaheen Posted August 29, 2010 Author Share Posted August 29, 2010 It works!!! Thanks for helping.... Quote Link to comment https://forums.phpfreaks.com/topic/211981-struggling-with-where-clause/#findComment-1104932 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.