passingTime Posted February 25, 2011 Share Posted February 25, 2011 Hello, Is there anyway to filter a recordset using an OR statement? for example: "SELECT * FROM DB1 WHERE example = %s" can i make it so it filters by 2? So something like: "SELECT * FROM DB1 WHERE example = %s or example2 = %s" Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/ Share on other sites More sharing options...
Maq Posted February 25, 2011 Share Posted February 25, 2011 Have you tried it? From you syntax, it looks like you should be using LIKE, not =. Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179579 Share on other sites More sharing options...
passingTime Posted February 25, 2011 Author Share Posted February 25, 2011 It works without the OR statement but i'm not sure how to use OR statements like this. So is that how you usually do it? Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179593 Share on other sites More sharing options...
Maq Posted February 25, 2011 Share Posted February 25, 2011 This is the correct logic but I'm telling you that the syntax is invalid. It should not work with or without the or like this. SELECT * FROM DB1 WHERE example = %s or example2 = %s Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179602 Share on other sites More sharing options...
Muddy_Funster Posted February 25, 2011 Share Posted February 25, 2011 Could you post your ACTUAL query (copy & paste) - it makes solving these things much easier Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179605 Share on other sites More sharing options...
passingTime Posted February 25, 2011 Author Share Posted February 25, 2011 Not something you solve i'm just asking if you can use OR statements and if so how. Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179629 Share on other sites More sharing options...
Maq Posted February 25, 2011 Share Posted February 25, 2011 i'm just asking if you can use OR statement Yes. and if so how Example: SELECT * FROM DB1 WHERE example LIKE '%s' OR example2 LIKE '%s'; Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179637 Share on other sites More sharing options...
passingTime Posted February 25, 2011 Author Share Posted February 25, 2011 Ok thanks i think i'll look into PHP and SQL a little more... Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179648 Share on other sites More sharing options...
passingTime Posted February 26, 2011 Author Share Posted February 26, 2011 Oh wait i made a mistake somewhere else but yeh that does actually work lol. Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1179957 Share on other sites More sharing options...
Maq Posted February 28, 2011 Share Posted February 28, 2011 Oh wait i made a mistake somewhere else but yeh that does actually work lol. Not sure what you're talking about. If you still need help post the query and error message. Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1180819 Share on other sites More sharing options...
fenway Posted March 1, 2011 Share Posted March 1, 2011 And again, post the solution. Link to comment https://forums.phpfreaks.com/topic/228808-or-statement/#findComment-1181065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.