Beginner

304. CONCAT_WS Function

Learn how to concatenate multiple values using a specified separator.

📘 Lesson 304 of 728 ⏱ 9 min 🎯 Intermediate

CONCAT_WS combines multiple string expressions using a specified separator between the values.

Using a separator makes it easier to create readable names, addresses, categories, and formatted business labels.

Combine city, state, and country using commas.

SQL
SELECT
    CONCAT_WS(', ', City, State, Country) AS FullAddress
FROM Customers;

CONCAT_WS is useful for address formatting, customer profiles, reporting labels, and data exports.

  • CONCAT_WS combines multiple values.
  • The first argument is the separator.
  • It simplifies formatted text creation.
  • It is useful for addresses.
  • Database support may vary.
What does CONCAT_WS mean?

CONCAT_WS combines strings using a specified separator.

How is CONCAT_WS different from CONCAT?

CONCAT_WS automatically places a specified separator between the values being combined.

Have you finished this lesson?

Introduction to SQL – All Lessons