The Code
SELECT * FROM info WHERE Name LIKE 'Keyword';
This way, you would get a ‘sort of search’, because you would have to type the name of the item 100% correctly, otherwise no results would show up. I guess this is sort of a ‘strict’ search, if something is slightly wrong, nothing would be returned.
Getting Less Strict
To get less ‘strict’ you would have to use the % wildcard, which will take the input keywords and find each item which has that keyword in it, depending on where you put it.
If you put the % wildcard after the query, your results would have to have the keyword at the beginning of the item you are trying to find, this is the opposite if you put the wildcard at the end of the query.
Examples
If your table had this data:
Name | Type |
---|---|
The Purge | TV Show |
The Deuce | TV Show |
The Detour | TV Show |
(1.) And your code was:
SELECT * FROM info WHERE Name LIKE 'The%';
(1.) Your output would be:
Name | Type |
---|---|
The Purge | TV Show |
The Deuce | TV Show |
The Detour | TV Show |
(2.) If your code was:
SELECT * FROM info WHERE Name LIKE 'he%';
(2.) Your output would be:
Name | Type |
---|---|
(Nothing) | (Nothing) |
(Nothing) | (Nothing) |
(Nothing) | (Nothing) |
(3.) If your code was:
SELECT * FROM info WHERE Name LIKE '%he%';
(3.) Your output would be:
Name | Type |
---|---|
The Purge | TV Show |
The Deuce | TV Show |
The Detour | TV Show |
That's It!
If you are looking to search through things such as Descriptions, this probably isn’t the way you want to search through them, you will most-likely want to use something like a Full-Text Search.