Skip to Content
0
Jun 15, 2016 at 07:03 AM

DB2 SQL - not like and <> get different result?

2098 Views

Hi,

Do you know why DB2 10.5.7 (I didn't test other) get different result for selects with "NOT LIKE" and "<>", when I set exact string for both? Seems ,that this difference is not in everytime. Me do it for OWNER column in syscat.tables. Bellow is example.

> db2 "select SUBSTR(TABSCHEMA,1,10) AS TABSCHEMA,SUBSTR(TABNAME,1,20) AS TABNAME,SUBSTR(OWNER,1,10) AS OWNER, TYPE, STATUS, CREATE_TIME, ALTER_TIME from syscat.tables where TABNAME = 'Z70_RN_VEN_TABL' AND OWNER not like 'SAPEST'"

TABSCHEMA TABNAME OWNER TYPE STATUS CREATE_TIME ALTER_TIME

---------- -------------------- ---------- ---- ------ -------------------------- --------------------------

SAPSR3 Z70_RN_VEN_TABL SAPEST T N 2013-05-11-15.17.26.378695 2013-05-11-15.17.26.658445

1 record(s) selected.

> db2 "select SUBSTR(TABSCHEMA,1,10) AS TABSCHEMA,SUBSTR(TABNAME,1,20) AS TABNAME,SUBSTR(OWNER,1,10) AS OWNER, TYPE, STATUS, CREATE_TIME, ALTER_TIME from syscat.tables where TABNAME like 'Z70_RN_VEN_TABL' AND OWNER <> 'SAPEST'"

TABSCHEMA TABNAME OWNER TYPE STATUS CREATE_TIME ALTER_TIME

---------- -------------------- ---------- ---- ------ -------------------------- --------------------------

0 record(s) selected.

B.R.

Martin