Jump to content

SQL "IN" statement help required please


gerkintrigg

Recommended Posts

Hello. I'd like to work out how to make the following work:

 

$sp_sql=mysql_query("select DISTINCT poked from pokes where poked IN(".$poked_by.") && poke_deleted='n' && !poked IN(".$double_pokes.")");
		while ($sp= mysql_fetch_array($sp_sql)){
		$single_pokes.=','.$sp['poked'];
		}

This is for this website... it's nothing rude...http://www.pigorpoke.com

 

I'm trying to select all from an array where the results' poked value are NOT in a string of numbers.

 

 

Link to comment
https://forums.phpfreaks.com/topic/38032-sql-in-statement-help-required-please/
Share on other sites

Nope, no errors @ this stage, jesirose, but it's still not working ;o)

 

I also tried

$sp_sql=mysql_query("select DISTINCT poked from pokes where poked IN($poked_by) && poke_deleted='n' && !poked IN($double_pokes)") or die(mysql_error());
		while ($sp= mysql_fetch_array($sp_sql) or die (mysql_error())){
		$single_pokes.=','.$sp['poked'];
		}

but this displays nothing...

 

Perhaps I need a left join?

 

i thought the code you wrote would work, and even tried it before trying to get some help on the forum. *shrug* weird innit?

Do this:

print "select DISTINCT poked from pokes where poked IN($poked_by) && poke_deleted='n' && !poked IN($double_pokes)"

What does it show? If the values aren't what you're expecting, there's the problem.

$poked_by and $double_pokes need to be comma separated strings like 1,2,3,4

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.