NEQ()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a boolean indicating if two values are not equivalent.
USAGE
NEQ(value1, value2)
Argument Name | Description |
---|---|
| The two values to compare |
DETAILS
NEQ()
is a function that compares two values, returning 0
(false) if both values are equivalent, otherwise 1
(true).
If at least one value is a number, a numeric comparison is performed. Thus, a string value is converted into a number when paired with a numeric value.
When both value are strings, the comparison takes into account the current sort order, which might treat uppercase and lowercase letters as equivalent. If you need to ignore case, consider negating the return value from IDENTICAL() or casting one of the string values to a BINARY
type.
A NULL
is returned if either argument is NULL
.
The function call NEQ(x, y)
behaves in exactly the same manner as the conditional expression x != y
.
EXAMPLES
SELECT NEQ(42, 42), NEQ(1, 0), NEQ(NULL, NULL);
+-------------+-----------+-----------------+
| NEQ(42, 42) | NEQ(1, 0) | NEQ(NULL, NULL) |
+-------------+-----------+-----------------+
| 0 | 1 | NULL |
+-------------+-----------+-----------------+
SELECT NEQ(99, 123),
NEQ(PI(), 3.141592653589793) AS pi_neq;
+--------------+--------+
| NEQ(99, 123) | pi_neq |
+--------------+--------+
| 1 | 0 |
+--------------+--------+
-- Disable strict mode or the select might throw an error
SET sql_mode = '';
SELECT NEQ(99, '99a'), NEQ('abc', 0);
+----------------+---------------+
| NEQ(99, '99a') | NEQ('abc', 0) |
+----------------+---------------+
| 0 | 0 |
+----------------+---------------+
CREATE TABLE neq_example (
description VARCHAR(20),
example INT
);
INSERT INTO neq_example VALUES
('Everything', 42),
('Dalmations', 101),
('Agent', 99),
('B. Doz.', 13),
('CPU', 64);
SELECT *
FROM neq_example
WHERE NEQ(example, 101) AND NEQ(description, 'B. Doz.');
+-------------+---------+
| description | example |
+-------------+---------+
| Everything | 42 |
| Agent | 99 |
| CPU | 64 |
+-------------+---------+