Click here to Skip to main content
15,911,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I have a datatable with columns (Id,Name,Price,Quantity)

in field Name I have data like:
Fox forest
Fox blue igua
Fox red mist
..
etc

I want to select all products which the have word fox inside
I tried
SELECT Id,Name,Price,Quantity
From Products
WHERE Name LIKE 'Fox'

but it didn't worked how imust modify my query in order to work properly?


Thnx in advance !!
Jason
Posted

SELECT Id,Name,Price,Quantity
From Products
WHERE Name LIKE '%Fox%'
 
Share this answer
 
SQL
SELECT Id,Name,Price,Quantity
From Products
WHERE Name LIKE 'Fox%'
 
Share this answer
 
use LIKE operator:
Like Operator is used in a WHERE clause to search for a specified pattern in a column.

% :- A substitute for zero or more characters
_ :- A substitute for a single character
[charlist] :- Sets and ranges of characters to match
[^charlist] or [!charlist] :- Matches only a character NOT specified within the brackets
SQL
SELECT ID,Name,Price,Quantity From Products WHERE Name LIKE '%Fox%'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900