Jump to content

Archived

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

cstegner

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
Crayon violet, you seem to always get the honors of making me feel like an idiot ;) Thanks.

Share this post


Link to post
Share on other sites
[!--quoteo(post=374657:date=May 17 2006, 10:27 AM:name=cstegner)--][div class=\'quotetop\']QUOTE(cstegner @ May 17 2006, 10:27 AM) [snapback]374657[/snapback][/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:

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

good luck!

Share this post


Link to post
Share on other sites

×

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.