使用MySQL php选择除三个以外的所有行

I was trying to use a select statement to get all the rows from a certain MySQL table except for three which has in user_id of 5,6,7. Below is the code but its not working properly. Please can you help.

$sql = "SELECT * FROM login ORDER BY user_id ASC LIMIT 0, 20 WHERE user_id<>5,6,7";

You have to Use NOT IN function for multiple id's.

$sql = "SELECT * FROM login WHERE user_id NOT IN (5,6,7) ORDER BY user_id ASC LIMIT 0, 20"

$sql = "SELECT * FROM login WHERE user_id<>5 ORDER BY user_id ASC LIMIT 0, 20 "

Look at Order by, Where Clause and Order of operations

As you've just changed your question the new answer is

$sql = "SELECT * FROM login WHERE user_id NOT IN (5,6,7) ORDER BY user_id ASC LIMIT 0, 20 "

Look at NOT IN

Do it like this:

 SELECT * FROM login WHERE NOT user_id = 5, ORDER BY user_id ASC LIMIT 0, 20

Try this:

$sql = "SELECT * FROM `login` WHERE `user_id` NOT IN (5,6,7) ORDER BY `user_id` ASC LIMIT 0, 20";