I'm trying to get the right syntax for the following case?
SELECT * FROM wp_posts AS p WHERE post_type = 'post' AND post_status = 'publish' AND ID <> 5616,1095,1357,271,2784,902 ORDER BY post_title DESC
not equal to (<>, !=) operator. MySQL Not equal is used to return a set of rows (from a table) after making sure that two expressions placed on either side of the NOT EQUAL TO (<>) operator are not equal.
Difference between SQL Not Equal Operator <> and != We can use both SQL Not Equal operators <> and != to do inequality test between two expressions. Both operators give the same output. The only difference is that '<>' is in line with the ISO standard while '!=
In MySQL, you can use the <> or != operators to test for inequality in a query. For example, we could test for inequality using the <> operator, as follows: SELECT * FROM contacts WHERE last_name <> 'Johnson';
Here is the answer – Technically there is no difference between != and <>. Both of them work the same way and there is absolutely no difference in terms of performance or result.
Instead of <>
, you can use NOT IN (5616,1095...)
SELECT * FROM wp_posts AS p WHERE post_type = 'post' AND post_status = 'publish' AND ID NOT IN (5616,1095,1357,271,2784,902) ORDER BY post_title DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With