第一:我正在運行postgresql 8.2並在pgAdmin上測試我的查詢。Postgresql案例和測試布爾字段
我有一些字段的表,說:
mytable(
id integer,
mycheck boolean,
someText varchar(200));
現在,我要與之相似,以這樣的查詢:
select id,
case when mycheck then (select name from tableA)
else (select name from tableB) end as mySpecialName,
someText;
我試圖運行並獲得這樣的:
ERROR: CASE types character varying and boolean cannot be matched
SQL state: 42804
甚至試圖愚弄postgresql與
case (mycheck::integer) when 0 then
沒有工作。
所以,我的問題是:因爲SQL沒有,如果,唯一的情況下,我如何設置如果與布爾字段?