Monday, January 20, 2025
HomeQ&AWhat is MySQL Not Equal?

What is MySQL Not Equal?

In MySQL, the NOT EQUAL operator is used to check whether two values are not equal to each other. There are two ways to write the NOT EQUAL condition:

  1. Using !=
  2. Using <>

Both operators are functionally identical and can be used interchangeably.

Syntax:

SELECT * FROM table_name
WHERE column_name != value;

or

SELECT * FROM table_name
WHERE column_name <> value;

Example:

Let’s assume we have a table called employees with a column age, and we want to select all employees whose age is not equal to 30:

SELECT * FROM employees
WHERE age != 30;

or

SELECT * FROM employees
WHERE age <> 30;

Both queries will return all records from the employees table where the age is not equal to 30.

See also  What Is The Lockport In The Laptop (Kensington Lock)?

Notes:

  • != and <> are the standard ways to represent “not equal” in SQL.
  • Be aware that NULL values are not considered equal to any other value, including NULL itself. To check for NULL values, you would use the IS NOT NULL condition.
RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x