[ https://issues.apache.org/jira/browse/DERBY-5893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13428647#comment-13428647 ]
Lukas Eder edited comment on DERBY-5893 at 8/4/12 5:39 PM: ----------------------------------------------------------- Yes, it's different in the way it handles NULLs. For example: - (1 != NULL) yields NULL, whereas (1 IS DISTINCT FROM NULL) yields TRUE - (NULL != NULL) yields NULL, whereas (NULL IS DISTINCT FROM NULL) yields FALSE Here's how you could translate IS [ NOT ] DISTINCT FROM into equivalent CASE expressions: -- A IS DISTINCT FROM B: CASE WHEN A IS NULL AND B IS NULL THEN 0 WHEN A IS NULL AND B IS NOT NULL THEN 1 WHEN A IS NOT NULL AND B IS NULL THEN 1 WHEN A = B THEN 0 ELSE 1 END -- A IS NOT DISTINCT FROM B: CASE WHEN A IS NULL AND B IS NULL THEN 1 WHEN A IS NULL AND B IS NOT NULL THEN 0 WHEN A IS NOT NULL AND B IS NULL THEN 0 WHEN A = B THEN 1 ELSE 0 END Alternatively, replace 1 and 0 by TRUE and FALSE. was (Author: lukas.eder): Yes, it's different in the way it handles NULLs. For example: - (1 != NULL) yields NULL, whereas (1 IS DISTINCT FROM NULL) yields TRUE - (NULL != NULL) yields NULL, whereas (NULL IS DISTINCT FROM NULL) yields FALSE Here's how you could translate IS [ NOT ] DISTINCT FROM into a equivalent CASE expressions: -- A IS DISTINCT FROM B: CASE WHEN A IS NULL AND B IS NULL THEN 0 WHEN A IS NULL AND B IS NOT NULL THEN 1 WHEN A IS NOT NULL AND B IS NULL THEN 1 WHEN A = B THEN 0 ELSE 1 END -- A IS NOT DISTINCT FROM B: CASE WHEN A IS NULL AND B IS NULL THEN 1 WHEN A IS NULL AND B IS NOT NULL THEN 0 WHEN A IS NOT NULL AND B IS NULL THEN 0 WHEN A = B THEN 1 ELSE 0 END Alternatively, replace 1 and 0 by TRUE and FALSE. > Add support for the SQL:2008 standard IS [ NOT ] DISTINCT FROM predicate > ------------------------------------------------------------------------ > > Key: DERBY-5893 > URL: https://issues.apache.org/jira/browse/DERBY-5893 > Project: Derby > Issue Type: Improvement > Components: SQL > Affects Versions: 10.9.1.0 > Reporter: Lukas Eder > Priority: Minor > Labels: features > > The SQL:1999 standard specifies the IS [ NOT ] DISTINCT FROM predicate in > chapter 8.15 <distinct predicate>: > <distinct predicate> ::= > <row value predicand 3> <distinct predicate part 2> > <distinct predicate part 2> ::= > IS [ NOT ] DISTINCT FROM <row value predicand 4> > <row value predicand 3> ::= > <row value predicand> > <row value predicand 4> ::= > <row value predicand> > This predicate is supported by at least these databases: > - http://www.postgresql.org/docs/9.1/static/functions-comparison.html > - http://www.h2database.com/html/grammar.html#condition_right_hand_side > - http://hsqldb.org/doc/guide/ch05.html#N11BB0 > - > http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#operator_equal-to > (with a different syntax) > - > http://dcx.sybase.com/1200/en/dbreference/is-distinct-from-search-condition.html > It would probably make sense for the Derby database to implement it as well. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira