Using CONCAT and CONCAT_WS to Combine Text in SQL
📖 Scenario: You are managing a small customer database for a local bookstore. You want to create a full name field by combining first and last names, and also create a contact info field by combining the full name with the email address, separated by a comma.
🎯 Goal: Build SQL queries that use CONCAT and CONCAT_WS functions to combine text columns into new fields.
📋 What You'll Learn
Create a table called
customers with columns id, first_name, last_name, and email.Insert three specific customer records into the
customers table.Write a query using
CONCAT to create a full_name column by joining first_name and last_name with a space.Write a query using
CONCAT_WS to create a contact_info column by joining full_name and email separated by a comma and space.💡 Why This Matters
🌍 Real World
Combining text fields like names and contact info is common in customer databases, reports, and user interfaces.
💼 Career
Knowing how to use CONCAT and CONCAT_WS helps database developers and analysts prepare readable and formatted data outputs.
Progress0 / 4 steps