Jump to content


Photo

A MySQL query, would it work?


  • Please log in to reply
3 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 12:47 PM

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'?
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 27 February 2006 - 01:13 PM

That won't work, but this will:

$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";


#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 27 February 2006 - 01:13 PM

[!--quoteo(post=349806:date=Feb 27 2006, 07:47 AM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Feb 27 2006, 07:47 AM) View Post[/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] * FROM AAForm WHERE Honor_Level = '$honor' AND Favourite_map_1 IN ('$map1', '$map2', '$map3') AND Favourite_map_2 IN ('$map_1', '$map_2', '$map3') AND Favourite_map_3 IN ('$map_1', '$map_2', '$map_3') ORDER BY Honor_Level ASC; [!--sql2--][/div][!--sql3--]

hope that helps

*EDIT*
*doh* wickning beat me to it ;-)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 01:19 PM

Thanks both of you! :D. that helped! i love you!!!!!!!!!
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users