Linux Postgres 勉強部屋
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 件のコメント:
コメントを投稿
次の投稿
前の投稿
ホーム
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿