We help IT Professionals succeed at work.
Get Started

select from array which not in table

630 Views
Last Modified: 2013-12-12
hello,

how can i select from array that these values not in table.

for example
<?php
$array = (1,2,3,4,5);

$array_str = my_implode("'","'",",", $array); //now  array_str is '1','2','3','4','5'

$s1 = mysql_query("select * from users where user_id not in ($array_str)"); // this returns me users not in this array

but i need

$s1 = mysql_query("select * from $array_str where $array_str not in users.user_id");

// how can i do with MySQL.

//Please dont answer php coding only SQL needed.
Thanks.

?>
Comment
Watch Question
Software Architect
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE