Mysql Where Not in Name Array?

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

2 Answers

Try this:

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

The MySQL CODE is

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest