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? Quote Link to comment 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) Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Loriq Posted June 9, 2008 Author Share Posted June 9, 2008 Thanks anyways Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.