我有一个jQuery列表,它在php页面上返回一个user_name列表,如
罗希特夏尔,Bhalu,拉姆
现在我想从数据库中过滤user_names,这不是上面列表的一部分
到目前为止,我正在尝试像
这样的mysql的基本查询 select * from table_name where user_name NOTIN('rohit','Bhalu','Ram');
但是上面的查询问题是,这不是包含1000个user_name的更大列表的具体解决方案所以我想使用一些带有php的查询过滤器
请建议我在这个阶段应该怎么做?
答案 0 :(得分:1)
首先使用字段user_name的索引。
第二次使用此查询(在$ 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)";