0
0
SQLquery~30 mins

WHERE with LIKE pattern matching in SQL - Mini Project: Build & Apply

Choose your learning style9 modes available
Filtering Customer Names Using WHERE with LIKE Pattern Matching
📖 Scenario: You work at a small online store. You have a list of customers in a database table. You want to find customers whose names start with certain letters.
🎯 Goal: Build a SQL query that selects customer names from a table called customers where the names match a pattern using the LIKE operator.
📋 What You'll Learn
Create a table called customers with a column name and insert exact customer names.
Create a variable pattern to hold the pattern string for matching names.
Write a SQL SELECT query that uses WHERE name LIKE pattern to filter customers.
Complete the query by adding a semicolon at the end.
💡 Why This Matters
🌍 Real World
Filtering customer or user data by name patterns is common in business reports and search features.
💼 Career
Knowing how to use WHERE with LIKE helps in writing queries for data filtering and reporting in many database jobs.
Progress0 / 4 steps
1
Create the customers table and insert data
Write SQL statements to create a table called customers with a column name of type VARCHAR(50). Then insert these exact customer names: 'Alice', 'Bob', 'Charlie', 'David', and 'Eve'.
SQL
Need a hint?

Use CREATE TABLE to make the table and INSERT INTO to add each customer name.

2
Define the pattern variable for matching names
Create a SQL variable called pattern and set it to the string 'A%' to match names starting with the letter A.
SQL
Need a hint?

Use DECLARE to create a variable and set it to 'A%'.

3
Write the SELECT query using WHERE with LIKE
Write a SQL SELECT statement to get the name column from the customers table where name LIKE pattern.
SQL
Need a hint?

Use SELECT name FROM customers WHERE name LIKE pattern to filter names.

4
Complete the SQL query with a semicolon
Add a semicolon ; at the end of the SELECT query to complete the SQL statement.
SQL
Need a hint?

Remember to end SQL statements with a semicolon ;.