Add SQL queries with NOT comparison

Original commit: elastic/x-pack-elasticsearch@88c76be0a4
This commit is contained in:
Costin Leau 2017-08-26 23:39:33 +03:00
parent a040f3bb14
commit 928c750585
1 changed files with 31 additions and 4 deletions

View File

@ -2,27 +2,54 @@
// Filter
//
whereFieldQuality
whereFieldEquality
SELECT last_name l FROM "test_emp" WHERE emp_no = 10000 LIMIT 5;
whereFieldNonEquality
SELECT last_name l FROM "test_emp" WHERE emp_no <> 10000 ORDER BY emp_no LIMIT 5;
whereFieldNonEqualityJavaSyntax
SELECT last_name l FROM "test_emp" WHERE emp_no != 10000 ORDER BY emp_no LIMIT 5;
whereFieldLessThan
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 ORDER BY emp_no LIMIT 5;
whereFieldAndComparison
SELECT last_name l FROM "test_emp" WHERE emp_no > 10000 AND emp_no < 10005 ORDER BY emp_no LIMIT 5;
whereFieldOrComparison
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 OR emp_no = 10005 ORDER BY emp_no LIMIT 5;
whereFieldEqualityNot
SELECT last_name l FROM "test_emp" WHERE NOT emp_no = 10000 LIMIT 5;
whereFieldNonEqualityNot
SELECT last_name l FROM "test_emp" WHERE NOT emp_no <> 10000 ORDER BY emp_no LIMIT 5;
whereFieldNonEqualityJavaSyntaxNot
SELECT last_name l FROM "test_emp" WHERE NOT emp_no != 10000 ORDER BY emp_no LIMIT 5;
whereFieldLessThanNot
SELECT last_name l FROM "test_emp" WHERE NOT emp_no < 10003 ORDER BY emp_no LIMIT 5;
whereFieldAndComparisonNot
SELECT last_name l FROM "test_emp" WHERE NOT (emp_no > 10000 AND emp_no < 10005) ORDER BY emp_no LIMIT 5;
whereFieldOrComparisonNot
SELECT last_name l FROM "test_emp" WHERE NOT (emp_no < 10003 OR emp_no = 10005) ORDER BY emp_no LIMIT 5;
whereFieldWithOrder
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 ORDER BY emp_no;
whereFieldWithExactMatchOnString
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 AND gender = 'M';
whereFieldWithNotEqualsOnString
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 AND gender <> 'M';
whereFieldWithLikeMatch
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 AND last_name LIKE 'K%';
whereFieldWithNegatedLikeMatch
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 AND last_name NOT LIKE 'K%';
whereFieldWithOrderNot
SELECT last_name l FROM "test_emp" WHERE NOT emp_no < 10003 ORDER BY emp_no LIMIT 5;
whereFieldWithExactMatchOnStringNot
SELECT last_name l FROM "test_emp" WHERE NOT (emp_no < 10003 AND gender = 'M') ORDER BY emp_no LIMIT 5;
whereFieldWithNotEqualsOnStringNot
SELECT last_name l FROM "test_emp" WHERE NOT (emp_no < 10003 AND gender <> 'M') ORDER BY emp_no LIMIT 5;
whereFieldWithLikeMatchNot
SELECT last_name l FROM "test_emp" WHERE NOT (emp_no < 10003 AND last_name NOT LIKE 'K%') ORDER BY emp_no LIMIT 5;
whereFieldOnMatchWithAndAndOr
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 AND (gender = 'M' AND NOT FALSE OR last_name LIKE 'K%') ORDER BY emp_no;
// TODO: (NOT) RLIKE, <>, <=>, !=
// TODO: (NOT) RLIKE in particular and more NOT queries in general
whereIsNotNullAndComparison
SELECT last_name l FROM "test_emp" WHERE emp_no IS NOT NULL AND emp_no < 10005 ORDER BY emp_no;