Crusader Posted December 12, 2006 Share Posted December 12, 2006 The basic query looks like this: "select * from table where column1=$value1 and column2=$value2 limit 1"There would be multiple values of $value1 and $value2 but I'd like to be able to call them all in one mysql_query rather than using a whole set of them then I'd like to output them.How would I do this?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/30297-solved-multiple-where-usage/ Share on other sites More sharing options...
btherl Posted December 12, 2006 Share Posted December 12, 2006 [code=php:0]select * from table where column1 IN ($value1, $value2) and column2 IN ($value3, $value4) limit 1[/code]That'll work if you want all combinations of all values. If you want only matching combinations, then I think you will need to do it the hard way:[code=php:0]select * from table where (column1 = $value1 and column2 = $value2) or ($column1 = $value3 and column2 = $value4) or ...[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30297-solved-multiple-where-usage/#findComment-139433 Share on other sites More sharing options...
Crusader Posted December 12, 2006 Author Share Posted December 12, 2006 [code] $xP=($x-1); $yP=($y-1); $xN=($x+1); $yN=($y+1); $cX=$xP; $cY=$yP;[/code]Your second solution looks like the best one to use for my case but I'm not quite sure on how to implement it. $value1 would be $cX and $value2 would be $cY. The values are incremented but I guess I could make an array for both of the values to make it work. select * from table where (column1 = $value1[1] and column2 = $value2[1]) or (column1 = $value1[2] and column2 = $value2[1]) or ...How would I output the results?e.g. the results for $value1[1] and $value2[2] are true but the results for $value1[2] and $value2[2] are false.Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/30297-solved-multiple-where-usage/#findComment-139443 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.