Comparison and List Operators
The following comparison and list operators are supported:
The comparison operators LT, LE, GT, GE, EQ, and NE must not be used as TABLE alias or COLUMN alias.
^= and GT
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1, tab2 t2 WHERE t1.c3 ^= t1.c3 AND t2.c4 GT 100; |
Output:
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1, tab2 t2 WHERE t1.c3 <> t1.c3 AND t2.c4 > 100; |
EQ and NE
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1 INNER JOIN tab2 t2 ON t1.c2 EQ t2.c2 WHERE t1.c6 NE 1000; |
Output:
1 2 3 4 5 |
SELECT t1.c1, t2.c2 FROM tab1 t1 INNER JOIN tab2 t2 ON t1.c2 = t2.c2 WHERE t1.c6 <> 1000; |
LE and GE
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1, tab2 t2 WHERE t1.c3 LE 200 AND t2.c4 GE 100; |
Output:
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1, tab2 t2 WHERE t1.c3 <= 200 AND t2.c4 >= 100; |
NOT= and LT
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1, tab2 t2 WHERE t1.c3 NOT= t1.c3 AND t2.c4 LT 100; |
Output:
1 2 3 4 |
SELECT t1.c1, t2.c2 FROM tab1 t1, tab2 t2 WHERE t1.c3 <> t1.c3 AND t2.c4 < 100; |
IN and NOT IN
For details, see IN and NOT IN Conversion.
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c1 IN 'XY'; |
Output:
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c1 = 'XY'; |
GaussDB(DWS) does not support IN and NOT IN operators in some specific scenarios.
IS NOT IN
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c1 IS NOT IN (subquery); |
Output:
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c1 NOT IN (subquery); |
LIKE ALL/NOT LIKE ALL
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c3 NOT LIKE ALL ('%STR1%', '%STR2%', '%STR3%'); |
Output:
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c3 NOT LIKE ALL (ARRAY[ '%STR1%', '%STR2%', '%STR3%' ]); |
LIKE ANY/NOT LIKE ANY
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c3 LIKE ANY ('STR1%', 'STR2%', 'STR3%'); |
Output:
1 2 3 |
SELECT c1, c2 FROM tab1 WHERE c3 LIKE ANY (ARRAY[ 'STR1%', 'STR2%', 'STR3%' ]); |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot