Cover Image for MySQL Not Equal
97 views

MySQL Not Equal

The MySQL Not Equal operator is used to compare values and check if they are not equal to each other. The “Not Equal” operator is represented by <> or !=. It returns TRUE if the values on the left and right sides of the operator are not equal and FALSE if they are equal.

Here’s the basic syntax for using the “Not Equal” operator:

value1 <> value2

or

value1 != value2

Here’s how it works:

  • value1 and value2 are the values you want to compare.
  • If value1 is not equal to value2, the expression evaluates to TRUE.
  • If value1 is equal to value2, the expression evaluates to FALSE.

Here are some examples to illustrate the use of the “Not Equal” operator:

  1. Match all records where the category is not equal to “Electronics”:
   SELECT *
   FROM products
   WHERE category <> 'Electronics';

or

   SELECT *
   FROM products
   WHERE category != 'Electronics';
  1. Retrieve customers who do not have a specific email address:
   SELECT *
   FROM customers
   WHERE email != '[email protected]';
  1. Find employees whose salary is not equal to a specific value:
   SELECT *
   FROM employees
   WHERE salary <> 50000;

The “Not Equal” operator is useful when you want to filter rows based on values that are different from a specific value or set of values. It allows you to exclude rows that meet certain conditions from your SQL query results.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS