Reputation: 11
For examples :
ID - Description
01 - Mix Black
02 - Mix Red
03 - Mix Blue
How I can write a query to show the field like "Mi Bl"
in a query?
Upvotes: 1
Views: 142
Reputation: 10138
You can use LIKE
with %
:
SELECT * FROM your_table WHERE Description LIKE 'Mi%Bl%';
This query would give you these 2 results:
01 - Mix Black
03 - Mix Blue
%
is a wildcard:
The percent sign represents zero, one, or multiple characters
Upvotes: 1
Reputation: 716
SELECT *
FROM Tablename
WHERE `Description` LIKE 'Mi%Bl%';
'%' character is used to match any number(0, 1 or more) of characters. So this will match to your below records and result set will be -
ID - Description
-------------------
01 - Mix Black
03 - Mix Blue
Upvotes: 0
Reputation: 8101
Use a LIKE clause with wildcard characters. https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql
SELECT *
FROM YourTable
WHERE Description LIKE 'Mi%Bl%';
This is SQL Server syntax, but any RDBMS will have a similar wildcard you can use.
Upvotes: 0