Jump to content

A MySQL query, would it work?


joecooper

Recommended Posts

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'?
Link to comment
https://forums.phpfreaks.com/topic/3671-a-mysql-query-would-it-work/
Share on other sites

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]
[!--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 ;-)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.