Minase Posted August 28, 2008 Share Posted August 28, 2008 hy there i am working on a new script,but it seem that this query doesnt work quite well .. $buddys = "SELECT * FROM `" . DBPREFIX . "buddys` WHERE `FID` = " . $user->ID . " OR `ID` = " . $user->ID . " AND `Type` = '1'"; i want the query to check if FID = $user->ID OR ID = $user->ID one of them, and Type = 1; thanks Link to comment https://forums.phpfreaks.com/topic/121759-solved-or-syntax/ Share on other sites More sharing options...
obsidian Posted August 28, 2008 Share Posted August 28, 2008 Without parenthesis, AND takes precedence, so your code is actually seeing if: FID = $user->ID OR (ID = $user->ID AND type = 1) So, you need to set off the OR with parentheticals: <?php $buddys = "SELECT * FROM `" . DBPREFIX . "buddys` WHERE (`FID` = " . $user->ID . " OR `ID` = " . $user->ID . ") AND `Type` = '1'"; ?> Link to comment https://forums.phpfreaks.com/topic/121759-solved-or-syntax/#findComment-628132 Share on other sites More sharing options...
Minase Posted August 28, 2008 Author Share Posted August 28, 2008 thank you,i did realize after i posted,how it interpret my query this work also $buddys = $db->RecordCount("SELECT * FROM `" . DBPREFIX . "buddys` WHERE `FID` = " . $user->ID . " AND `Type` = '1' OR `ID` = " . $user->ID . " AND `Type` = '1'"); Link to comment https://forums.phpfreaks.com/topic/121759-solved-or-syntax/#findComment-628136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.