Jump to content

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 ;-)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.