Firebird 的 select 子句中是否可以使用布尔表达式?

Is it possible to have boolean expressions in the select-clause in Firebird?

在 mysql 中你可以做 select name <> '' from persons where person_id = 1000 并且它会 return 一个 1 或零,有没有办法在 Firebird 中用 DML 做类似的事情?根据我能够确定的,我猜不是。

在 Firebird 3 及更高版本中这是可能的,因为 BOOLEAN 数据类型的引入现在允许在 select 子句中使用这种类型的表达式。这样的布尔表达式将 return true/false,尽管某些工具可能会为您将其映射为 1/0。

在 Firebird 2.5 及更早版本中,您必须自己映射它,例如使用 CASE:

select case when name <> '' then 1 else 0 end from atable where person_id = 1000

IIF:

select iif(name <> '', 1, 0) from atable where person_id = 1000

这也适用于 Firebird 3 及更高版本。