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 Link to comment https://forums.phpfreaks.com/topic/7728-sql-or-statement/ 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 Link to comment https://forums.phpfreaks.com/topic/7728-sql-or-statement/#findComment-28216 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 Link to comment https://forums.phpfreaks.com/topic/7728-sql-or-statement/#findComment-28243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.