我想排除这些名称为
的专辑$ban_album_names = array('Wall', 'Profile', 'Cover', 'Instagram');
我如何正确写作,
SELECT * FROM albums WHERE name NOT IN ???
如何让它在数组中查看,如果名称匹配则应该!=行
答案 0 :(得分:67)
试试这个:
$sql = "SELECT *
FROM albums
WHERE name NOT IN ( '" . implode( "', '" , $ban_album_names ) . "' )";
答案 1 :(得分:25)
MySQL代码是
SELECT * FROM albums WHERE name NOT IN ('Wall', 'Profile', 'Cover', 'Instagram')