Canman2005 Posted April 18, 2006 Share Posted April 18, 2006 Dear allI have this sql statement[code]$sql = "SELECT * FROM members WHERE year = $year AND membership_no =".$_SESSION['MEMIDD'];[/code]As well as selecting all rows which match the session ID for membership number, I want to pull in all rows which have the membership_no as 0, I tried[code]$sql = "SELECT * FROM members WHERE year = $year AND membership_no = 0 AND membership_no =".$_SESSION['MEMIDD'];[/code]but it didnt seem to like thatAny ideas?Thanks in advanceEd Quote Link to comment Share on other sites More sharing options...
shocker-z Posted April 18, 2006 Share Posted April 18, 2006 try this:$sql = "SELECT * FROM members WHERE year = '$year' AND membership_no = 0 AND membership_no = '".$_SESSION['MEMIDD']."'";just basicaly put $_SESSION['memidd'] inside ' ' in the query as well as $year :)RegardsLiam Quote Link to comment Share on other sites More sharing options...
Roberto Posted April 18, 2006 Share Posted April 18, 2006 [!--quoteo(post=366057:date=Apr 18 2006, 04:55 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Apr 18 2006, 04:55 PM) [snapback]366057[/snapback][/div][div class=\'quotemain\'][!--quotec--]try this:$sql = "SELECT * FROM members WHERE year = '$year' AND membership_no = 0 AND membership_no = '".$_SESSION['MEMIDD']."'";[/quote]Surely it should be[code]$sql = "SELECT * FROM members WHERE year = '$year' AND (membership_no = 0 OR membership_no = '".$_SESSION['MEMIDD']."')"; [/code]Note the OR and the ()Rob Quote Link to comment 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.