udb

Datatype conversion in IBM DB2: BIGINT to VARCHAR

[亡魂溺海] 提交于 2019-12-08 21:53:08
问题 I'm writing a query to do some stuff. But its not working the way I want it to: select CORR_ID from TABLE1 where CORR_ID not in (select id from TABLE2) The problem is, TABLE2.id is a long, while TABLE1.CORR_ID is a string. So how can I make it work? PS: I'm using IBM UDB. 回答1: Okay, I found a method: select CORR_ID from TABLE1 where CORR_ID not in (select CAST( CAST(id AS CHAR(50)) AS VARCHAR(50) ) from TABLE2) This is pretty intriguing: You can't cast a BIGINT to VARCHAR, but: you can cast a