0

I have a jQuery list which is returning a list of user_name on php page like

rohit,Bhalu,Ram

Now I want to filter the user_names from the database which is not the part of above list

So far I am trying the basic query of mysql like

 select * from table_name where user_name NOTIN('rohit','Bhalu','Ram');

But problem with above query is, this a not the specific solution for bigger list which contains 1000 user_name so I want to use some query filter with php

Please suggest me what should I do in this stage ?

1 Answer 1

1

First use index for field user_name.

Second use this query (in $array - usernames)

$array = array('Rohit', 'Bhalu');
$comma_separated = implode("','", $array);
$comma_separated = "'".$comma_separated."'";
$query = "select * from table_name where user_name NOT IN($comma_separated)";
Sign up to request clarification or add additional context in comments.

2 Comments

CREATE INDEX key_user_name ON table_name (user_name);
ok now my $array = Array ( [0] => rohit [1] => Bhalu ) but still its not working for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.