MySQL返回的行与PHP数组中的值不相等

时间:2013-06-06 21:31:28

标签: php mysql

$query = $this->db->query("SELECT * FROM default_albums da
                               INNER JOIN default_album_hc_connect d ON d.albums_id = da.album_id_da
                               INNER JOIN default_hottest_categories dhc ON dhc.id = d.hottest_categories_id
                               WHERE dhc.is_hottest = 'Yes'");

以上是我目前的查询。我有一个名为结果的数组,正在从ajax帖子中提取。如何获取该数组并返回与该数组中的值不相等的行?

1 个答案:

答案 0 :(得分:1)

NOT IN条件怎么样?

" (...)
WHERE (...)
    AND whatever NOT IN (\"" . implode('", "', $array) . "\")";