Select column, if blank select from another

前端 未结 4 1428
谎友^
谎友^ 2020-12-24 11:29

How does one detect whether a field is blank (not null) and then select another field if it is?

What I really need is a IsBlank function that works the same as IsNul

4条回答
  •  一向
    一向 (楼主)
    2020-12-24 11:52

    EDIT: You can't use IF() in mssql.

    Use an IF statement in the SELECT portion of your SQL:

    SELECT IF(field1 != '', field1, field2) AS myfield FROM ...
    

提交回复
热议问题