Loriq Posted June 8, 2008 Share Posted June 8, 2008 What is the proper way to do this as one condition, instead of multiple conditions connected by ands? This is how it's being made right now select `stuff` from `table` where `tinyint`&~15 = 32 and `tinyint`%16 = 10 select `stuff` from `table` where `tinyint`&~15 = 2 and `tinyint`%16 = 3 select `stuff` from `table` where `tinyint`&~15 = 64 and `tinyint`%16 = 0 select `stuff` from `table` where `tinyint`&~15 = 16 and `tinyint`%16 = 13 etc.. and the PHP code $query='select `stuff` from `table` where `tinyint`&~15 = '.($var1<<4).' and `tinyint`%16 = '.$var2; But I want to make it into a single condition so that MySQL will only need to check once. How do I do this? Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/ Share on other sites More sharing options...
luca200 Posted June 9, 2008 Share Posted June 9, 2008 select `stuff` from `table` where (`tinyint`&~15 = 32 and `tinyint`%16 = 10) or (`tinyint`&~15 = 2 and `tinyint`%16 = 3) or (`tinyint`&~15 = 64 and `tinyint`%16 = 0) or (`tinyint`&~15 = 16 and `tinyint`%16 = 13) Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/#findComment-560953 Share on other sites More sharing options...
Loriq Posted June 9, 2008 Author Share Posted June 9, 2008 I guess I wasn't clear, sorry. I just gave 4 examples of the query to try to make it more clear. Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/#findComment-561056 Share on other sites More sharing options...
luca200 Posted June 9, 2008 Share Posted June 9, 2008 I guess it was me not reading with attention I don't think you can do as you want, unless you have a strong link between $var1 and $var2 Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/#findComment-561067 Share on other sites More sharing options...
Loriq Posted June 9, 2008 Author Share Posted June 9, 2008 Both are numbers between 0 and 12, if that helps. Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/#findComment-561071 Share on other sites More sharing options...
luca200 Posted June 9, 2008 Share Posted June 9, 2008 I'm afraid no. I don't see any way to get those two conditions to one Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/#findComment-561088 Share on other sites More sharing options...
Loriq Posted June 9, 2008 Author Share Posted June 9, 2008 Thanks anyways Link to comment https://forums.phpfreaks.com/topic/109288-solved-merge-multiple-conditions-in-to-one/#findComment-561108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.