Jump to content


Photo

What's the opposite of id IN ('$id array')


  • Please log in to reply
3 replies to this topic

#1 cstegner

cstegner
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 17 May 2006 - 02:27 PM

I need a query that will in essence be saying NOT IN ('$id_array') how do I do that?

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 17 May 2006 - 02:34 PM

by saying NOT IN
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 cstegner

cstegner
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 17 May 2006 - 02:42 PM

Crayon violet, you seem to always get the honors of making me feel like an idiot ;) Thanks.

#4 obsidian

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

Posted 17 May 2006 - 02:57 PM

[!--quoteo(post=374657:date=May 17 2006, 10:27 AM:name=cstegner)--][div class=\'quotetop\']QUOTE(cstegner @ May 17 2006, 10:27 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I need a query that will in essence be saying NOT IN ('$id_array') how do I do that?
[/quote]

if you have an array in a variable, just implode it with the quotes you need and stick it right into your query:

<?php
$array = array("blue", "green", "violet");
$sql = mysql_query("SELECT * FROM tableName WHERE color NOT IN ('" . implode("', '", $array) . "')");
?>

good luck!
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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users