Reputation: 1
Please clarify what information is pulled and how it is reorganized using CONCAT vs CONCAT_WS in SQL. See example below for more details.
For example,
CONCAT('Google', '.com') creates Google.com
but I don't understand how
CONCAT_WS ('.', 'www', 'google', 'com') also create Google .com
To me it seems like it would create .wwwgooglecom
Why is this not the case?
For example,
CONCAT('Google', '.com') creates Google.com
but I don't understand how
CONCAT_WS ('.', 'www', 'google', 'com') also create Google .com
To me it seems like it would create .wwwgooglecom
Why is this not the case?
Upvotes: -2
Views: 809
Reputation: 11
CONCAT_WS
will handle NULL
values as empty strings, whereas CONCAT
will return NULL.
Upvotes: 1
Reputation: 11
CONCAT
just combines the values provided as arguments as it is. For example - CONCAT('www','.google','.com')
produces www.google.com
CONCAT_WS
will combine the provided values based on the separator, which is the first argument. For example -
CONCAT_WS('.', 'www','google','com')
will produce www.google.com
.
Upvotes: 0