joecooper Posted February 27, 2006 Share Posted February 27, 2006 SELECT * FROM AAForm WHERE Honor_Level="$honor" AND Favourite_map_1='$map1' or '$map2 or '$map3' AND Favourite_map_2='$map1' or '$map2 or '$map3' AND Favourite_map_2='$map1' or '$map2 or '$map3' ORDER BY Horor_Level ASC";this is my lenghty MySQL query. i cant test it as i dont have acess to the server yet, but i done this out of my head, would it work?so like a feild called "Favorite_map_2" = $map1 OR $map2 ect.. can you do 'OR'? Quote Link to comment https://forums.phpfreaks.com/topic/3671-a-mysql-query-would-it-work/ Share on other sites More sharing options...
wickning1 Posted February 27, 2006 Share Posted February 27, 2006 That won't work, but this will:[code]$sql = "SELECT * FROM AAForm WHERE Honor_Level='$honor' AND Favourite_map_1 IN ('$map1', '$map2', '$map3') AND Favourite_map_2 IN ('$map1', '$map2', '$map3') AND Favourite_map_3 IN ('$map1', '$map2', '$map3') ORDER BY Honor_Level ASC";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3671-a-mysql-query-would-it-work/#findComment-12710 Share on other sites More sharing options...
obsidian Posted February 27, 2006 Share Posted February 27, 2006 [!--quoteo(post=349806:date=Feb 27 2006, 07:47 AM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Feb 27 2006, 07:47 AM) [snapback]349806[/snapback][/div][div class=\'quotemain\'][!--quotec--]SELECT * FROM AAForm WHERE Honor_Level="$honor" AND Favourite_map_1='$map1' or '$map2 or '$map3' AND Favourite_map_2='$map1' or '$map2 or '$map3' AND Favourite_map_2='$map1' or '$map2 or '$map3' ORDER BY Horor_Level ASC";this is my lenghty MySQL query. i cant test it as i dont have acess to the server yet, but i done this out of my head, would it work?so like a feild called "Favorite_map_2" = $map1 OR $map2 ect.. can you do 'OR'?[/quote]as-is, it won't work. the most concise way i can think to write that would be:[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]FROM[/color] [color=orange]AAForm[/color] [color=green]WHERE[/color] Honor_Level [color=orange]=[/color] [color=red]'$honor'[/color] [color=blue]AND[/color] Favourite_map_1 [color=green]IN[/color] ([color=red]'$map1'[/color], [color=red]'$map2'[/color], [color=red]'$map3'[/color]) [color=blue]AND[/color] Favourite_map_2 [color=green]IN[/color] ([color=red]'$map_1'[/color], [color=red]'$map_2'[/color], [color=red]'$map3'[/color]) [color=blue]AND[/color] Favourite_map_3 [color=green]IN[/color] ([color=red]'$map_1'[/color], [color=red]'$map_2'[/color], [color=red]'$map_3'[/color]) [color=green]ORDER BY[/color] Honor_Level ASC; [!--sql2--][/div][!--sql3--]hope that helps[b]*EDIT*[/b]*doh* wickning beat me to it ;-) Quote Link to comment https://forums.phpfreaks.com/topic/3671-a-mysql-query-would-it-work/#findComment-12711 Share on other sites More sharing options...
joecooper Posted February 27, 2006 Author Share Posted February 27, 2006 Thanks both of you! :D. that helped! i love you!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/3671-a-mysql-query-would-it-work/#findComment-12712 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.