MySQL Not EqualMySQL Not Equal is an inequality operator that used for returning a set of rows after comparing two expressions that are not equal. The MySQL contains two types of Not Equal operator, which are (< >) and (! =). Difference Between (< >) and (! =) OperatorThe Not Equal operators in MySQL works the same to perform an inequality test between two expressions. They always give the same result. However, they contain one difference that “< >” follows the ISO standard whereas “!=” does not follow ISO standard. Example 1Let us create a table student to understand how Not Equal operator works in MySQL. Suppose the “students” table contains the following data: Table: students If you want to get the student details who do not belong to England, then you need to execute the following statement: OR, After successful execution of the above queries, we will get the same output as below: Example 2In this example, we are going to understand how Not Equal operator works with Group By clause. We can use the Group By clause for grouping rows that have the same data. If we want to get all customers who do not have cellphone number and duplicate income value, execute the following statement: We will get the following output: Example 3In this example, we are going to understand how Not Equal operator works with a JOIN statement. Let us create a table "contacts" and "customers" in a database that contains the following data: Table: contacts Table: customers If we want to get all the records from table customers and contacts where the cellphone is Null, execute the following statement that returns all customers who do not have a cellphone number: After successful execution, it will give the following output: Example 4In this example, we are going to understand how the Not Equal operator works with multiple conditions in the WHERE clause. For example, we want to get the customer details where income is higher than 40000, and occupation is not a developer. Execute the following statement to get the result: After the successful execution of the above statement, we will get the following output. Next TopicMySQL IS NULL Condition |