由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - better way to compare nullable columns?
相关主题
compare two large tables SQL (转载)How to replace 0 with empty?
请问sql 有条件性的select columnsHow to get other columns after UNION?
Null in C and Null in OracleTable Merge (SQL Server)
sql server 面试题 (9)其实有个问题好久没有明白!
请教oracle sql query questiona simple question about insert
请教三个Key的property,Oracle Group and Index question
have a simple question. Please help me!问个external table field definition的问题
一个奇怪的问题How to handle inserting value to Identity column in sql server 2005
相关话题的讨论汇总
话题: null话题: nvl话题: nullable话题: compare话题: way
进入Database版参与讨论
1 (共1页)
c**t
发帖数: 2744
1
in oracle, join table a and b on col, which is a nullable column
a.col = b.col doesn't match all
( a.col is null and b.col is null )
OR
( a.col is not null and b.col is not null and a.col = b.col )
does
nvl(a.col, 'N/A') = nvl( b.col, 'N/A') seems work, but if a.col is null and
b.col is 'N/A', then it will fail.
What's the best way to compare them?
B*****g
发帖数: 34098
2
why nvl not work?

and

【在 c**t 的大作中提到】
: in oracle, join table a and b on col, which is a nullable column
: a.col = b.col doesn't match all
: ( a.col is null and b.col is null )
: OR
: ( a.col is not null and b.col is not null and a.col = b.col )
: does
: nvl(a.col, 'N/A') = nvl( b.col, 'N/A') seems work, but if a.col is null and
: b.col is 'N/A', then it will fail.
: What's the best way to compare them?

c**t
发帖数: 2744
3
can't predict the a.col doesn't include 'N/A'

【在 B*****g 的大作中提到】
: why nvl not work?
:
: and

B*****g
发帖数: 34098
4
hehe, I believe N/A is null.

【在 c**t 的大作中提到】
: can't predict the a.col doesn't include 'N/A'
k*********y
发帖数: 41
5
try Coalesce
http://www.techonthenet.com/oracle/functions/coalesce.php

and

【在 c**t 的大作中提到】
: in oracle, join table a and b on col, which is a nullable column
: a.col = b.col doesn't match all
: ( a.col is null and b.col is null )
: OR
: ( a.col is not null and b.col is not null and a.col = b.col )
: does
: nvl(a.col, 'N/A') = nvl( b.col, 'N/A') seems work, but if a.col is null and
: b.col is 'N/A', then it will fail.
: What's the best way to compare them?

B*****g
发帖数: 34098
6
how this works?

【在 k*********y 的大作中提到】
: try Coalesce
: http://www.techonthenet.com/oracle/functions/coalesce.php
:
: and

c**t
发帖数: 2744
7
the main reason is to avoid comparing nulls, apparently coalsece won't work.

【在 B*****g 的大作中提到】
: how this works?
c*****t
发帖数: 1879
8
你是说,你的 string 数值有正常的 value,null, 和 'N/A' ?

and

【在 c**t 的大作中提到】
: in oracle, join table a and b on col, which is a nullable column
: a.col = b.col doesn't match all
: ( a.col is null and b.col is null )
: OR
: ( a.col is not null and b.col is not null and a.col = b.col )
: does
: nvl(a.col, 'N/A') = nvl( b.col, 'N/A') seems work, but if a.col is null and
: b.col is 'N/A', then it will fail.
: What's the best way to compare them?

c**t
发帖数: 2744
9
yes

【在 c*****t 的大作中提到】
: 你是说,你的 string 数值有正常的 value,null, 和 'N/A' ?
:
: and

s******s
发帖数: 508
10
Use another string then.
e.g.
nvl(a.col,'NULL')=nvl(b.col,'NULL')
or even use the following if you like,
nvl(a.col,'Fuck off, it is null')=nvl(b.col,'Fuck off, it is null')

and

【在 c**t 的大作中提到】
: in oracle, join table a and b on col, which is a nullable column
: a.col = b.col doesn't match all
: ( a.col is null and b.col is null )
: OR
: ( a.col is not null and b.col is not null and a.col = b.col )
: does
: nvl(a.col, 'N/A') = nvl( b.col, 'N/A') seems work, but if a.col is null and
: b.col is 'N/A', then it will fail.
: What's the best way to compare them?

1 (共1页)
进入Database版参与讨论
相关主题
How to handle inserting value to Identity column in sql server 2005请教oracle sql query question
%如何把一个table所有的column都选出来%请教三个Key的property,
SQL aggregate multiple columns in ACCESShave a simple question. Please help me!
用SSIS EXPORT 到 EXCEL 2010 有2000个COLUMN,可能吗一个奇怪的问题
compare two large tables SQL (转载)How to replace 0 with empty?
请问sql 有条件性的select columnsHow to get other columns after UNION?
Null in C and Null in OracleTable Merge (SQL Server)
sql server 面试题 (9)其实有个问题好久没有明白!
相关话题的讨论汇总
话题: null话题: nvl话题: nullable话题: compare话题: way