phporcaffeine Posted April 29, 2006 Share Posted April 29, 2006 Okay,Here is the basis of my querySELECT col_1, col_2, col_4, col_8 FROM tbl_name WHERE status='value_1' OR status='value_2' AND company='value';Of course it bombs and I know it's because of " AND company='value' " I'm guessing that I can't do status="value_1' OR status='value_2' - plus - AND company=' 'It doesn't make 'boolean' sense, I know.I'm hoping there is a way around this? Link to comment https://forums.phpfreaks.com/topic/8729-solved-mysql-select-help/ Share on other sites More sharing options...
Barand Posted April 29, 2006 Share Posted April 29, 2006 Queries using AND and OR can be ambiguous so use (...) to make sure the logic is clearDo you mean[code]...WHERE ((status='value_1') OR (status='value_2')) AND company='value'[/code]or[code]...WHERE (status='value_1') OR ( status='value_2' AND company='value')[/code]if it's the former, a clearer alternative is[code]...WHERE status IN ('value_1' , 'value_2') AND company='value'[/code] Link to comment https://forums.phpfreaks.com/topic/8729-solved-mysql-select-help/#findComment-32056 Share on other sites More sharing options...
phporcaffeine Posted April 30, 2006 Author Share Posted April 30, 2006 [!--quoteo(post=369982:date=Apr 29 2006, 07:35 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 29 2006, 07:35 PM) [snapback]369982[/snapback][/div][div class=\'quotemain\'][!--quotec--]Queries using AND and OR can be ambiguous so use (...) to make sure the logic is clearDo you mean[code]...WHERE ((status='value_1') OR (status='value_2')) AND company='value'[/code]or[code]...WHERE (status='value_1') OR ( status='value_2' AND company='value')[/code]if it's the former, a clearer alternative is[code]...WHERE status IN ('value_1' , 'value_2') AND company='value'[/code][/quote]Thanks! It Worked Link to comment https://forums.phpfreaks.com/topic/8729-solved-mysql-select-help/#findComment-32092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.