php MySQL 在哪里不在名称数组中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12230338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:05:51  来源:igfitidea点击:

MySQL where NOT IN name array?

phpmysqlsql

提问by Karem

I would like to exclude these albums, that has name:

我想排除这些具有名称的专辑:

$ban_album_names = array('Wall', 'Profile', 'Cover', 'Instagram');

How do I write correctly,

怎么写才正确

SELECT * FROM albums WHERE name NOT IN ???

How can I make it look in the array, and if the name matches it should != the row

我怎样才能让它在数组中查找,如果名称匹配,它应该 != 行

回答by hjpotter92

Try this:

尝试这个:

$sql = "SELECT *
    FROM albums
    WHERE name NOT IN ( '" . implode( "', '" , $ban_album_names ) . "' )";

回答by catalinux

The MySQL CODE is

MySQL 代码是

SELECT * FROM albums WHERE name NOT IN ('Wall', 'Profile', 'Cover', 'Instagram')