本表中select语句判断怎么做?
有表结构如下
cat_id cat_name cat_name_bm
1 test_a test
2 test_b test
3 test_c test_c
cat_name和cat_name_bm中只取一个字段名称。判断cat_name_bm的字段,如果检测到字段cat_name_bm='test'的时候,取cat_name字段,
cat_name_bm<>'test'时取cat_name_bm。
在使用select 语句中希望得到的结果是
cat_id cat_name
1 test_a
2 test_b
3 test_c
我写了个
select (if cat_name_bm<>'test' then cat_name_bm else cat_name end if) from fcst_cat
通不过。
麻烦各位了。