Operator Table

Operator Description
% It is used in substitute of zero or more characters.
_ It is used as a substitute for one character.
It is used to substitute a range of characters.
[range_of_characters] It is used to fetch a matching set or range of characters specified inside the brackets.

Syntax

SELECT column1,column2 FROM table_name 

WHERE column LIKE wildcard_operator;

column1,column2: fields in the table

table_name: name of the table

column: name of the field used for filtering data

CREATE Table Customer

CREATE TABLE Customer(
CustomerID INT PRIMARY KEY,
CustomerName VARCHAR(50),
LastName VARCHAR(50),
Country VARCHAR(50),
Age int(2),
Phone int(10)
);
-- Insert some sample data into the Customers table
INSERT INTO Customer (CustomerID, CustomerName, LastName, Country, Age, Phone)
VALUES (1, 'Shubham', 'Thakur', 'India','23','9125368745'),
(2, 'Aman ', 'Chopra', 'Australia','21','9632784152'),
(3, 'Naveen', 'Tulasi', 'Sri lanka','24','8965741538'),
(4, 'Aditya', 'Arpan', 'Austria','21','9874589736'),
(5, 'Nishant. Salchichas S.A.', 'Jain', 'Spain','22','8754128965');
Select * from Customer;

Output

Customer Table

SQL | Wildcard operators

Wildcard operators are used with the LIKE operator, which is generally used to search the data in the database and there are four basic operators %, _,-,[range_of_chracters]. Let us explain all these operators in brief –

Similar Reads

Operator Table

Operator Description % It is used in substitute of zero or more characters. _ It is used as a substitute for one character. – It is used to substitute a range of characters. [range_of_characters] It is used to fetch a matching set or range of characters specified inside the brackets....

Using the % Wildcard

...

Using the _ Wildcard

...

Using the [Charlist] Wildcard

1. To fetch records from the Customer table with LastName containing letters ‘a, ‘b’, or ‘c’....

Using Both % and _ Wildcard

1. To fetch records from the Student table with the PHONE field having an ‘8’ in the 1st position and a ‘3’ in the 3rd position....

FAQs on WildCard Operator

Q 1: What is a wildcard operator in SQL?...

Contact Us