Set default value in query when value is null

前端 未结 6 1395
难免孤独
难免孤独 2021-02-04 08:16

I\'m running a really simple query, however for some of the results the value in one field is null. How can I set that value to \"a string\" if its value is null?

Someth

6条回答
  •  心在旅途
    2021-02-04 09:11

    You just use ISNULL(website, 'yourstring').

    So, your query will be like:

    SELECT RegName,
        RegEmail,
        RegPhone,
        RegOrg,
        RegCountry,
        DateReg,
        ISNULL(website, 'no website') AS WebSite
    FROM RegTakePart
    WHERE Reject IS NULL
    

提交回复
热议问题