SELECT
EMPLOYEE.EMPLOYEE_FNAME + EMPLOYEE.EMPLOYEE_LNAME +
EMPLOYEE.EMPLOYEE_PRIMARY_NUMBER + EMPLOYEE.EMPLOYEE_EMAIL AS EMPLOYEE,
ADDRESS.ADDRESS_LINE_1开发者_Go百科 + ADDRESS.ADDRESS_LINE_2 + ADDRESS.CITY_PROVINCE +
ADDRESS.STATE_ABBREVIATION + ADDRESS.POSTAL_CODE AS ADDRESS
FROM
EMPLOYEE
INNER JOIN
ADDRESS ON EMPLOYEE.ADDRESS_ID = ADDRESS.ADDRESS_ID
You need to ensure that no data is null
isnull(ADDRESS.ADDRESS_LINE_1, '')
+ isnull(....
If you concatenate a string and a null value, the result is null.
Use coalesce
or isnull
to make sure that you don't have a null value:
ADDRESS.ADDRESS_LINE_1 + COALESCE(ADDRESS.ADDRESS_LINE_2, '')
You can override the default options for null concatenation with this:
SET CONCAT_NULL_YIELDS_NULL OFF
精彩评论