2009年5月28日木曜日

SQLでWhere文を可変にする。

isnullが使える場合は
select * from foo where isnull(name,'') = isnull((case when @x is not null then '太郎' else name end),'')

postgresSQLの場合
COALESCE(A,0) = COALESCE((case when A is not null then B else A),0)
でいける。

0 件のコメント:

コメントを投稿