-
SQL Installing SSMS
-
SQL Syntax
-
SQL Datatype
-
SQL Database
-
SQL Table
-
SQL Select
-
SQL Distinct
-
SQL Count
-
SQL Top
-
SQL Aliases
-
SQL In
-
SQL Insert
-
SQL Update
-
SQL Null
-
SQL Like
-
SQL Wildcards
-
SQL Nested Query
-
SQL Between
-
SQL Unique
-
SQL Primary Key
-
SQL Foreign Key
-
SQL Check
-
SQL Default
-
SQL Database Diagram
-
SQL Stored Procedures
-
SQL Joins
-
SQL Inner Join
-
SQL Left Join
-
SQL Right Join
-
SQL Full Join
-
SQL Trigger
SQL Wildcard
A wildcard character is used to substitute one or more characters in a string. Wildcard characters are used with the LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
Example:
SELECT column_Name1, column_Name2 …., column_NameN FROM table_Name WHERE column_name LIKE pattern:
Let’s take the following Employee table:
Return all customers starting with either “b”, “s”, or “p”:
SELECT * FROM Employee WHERE Name LIKE ‘[rsv]%’;
The [] wildcard returns a result if any of the characters inside gets a match.
Output:
Let’s take the following Student table:
Return all customers starting with “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j” or “k”:
SELECT * FROM Name WHERE Name LIKE ‘[a-k]%’;
Output:
The – wildcard allows you to specify a range of characters inside the [] wildcard.
Course Video
NOTE: Practice below questions on site editor.
1. Write SQL query to get Firstname, Lastname, from Person_Person table where firstname starts with ‘b’.
Output:
2. Write SQL query to get addressline1, addressline2, city from person.address table where city start with ’M_ N’ .
Output:
3. Write SQL query to get productid, name, color, listprice from Production_Product table where productname start with ‘Adjustable Race’.
Output:
5. Write a query to fetch the city name start with ‘p’.
Table name:(Person_Address)
Output:
YouTube Reference :
1) SQL Wildcard in Hindi/Urdu
2) SQL Wildcard in English