• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Way to search SQL database to see if it contains keywords?

GoingUp

Lifer
Writing a search function for ASP .NET with SQL and I want people to be able to search by keywords. Is there an SQL statement that I can write so that the product description field gets searched?

EG.

If the keyword is "light" I want the database to retrun every item in which one of the words in product description contains the word "light" E.G. Light bulb, light grey, flashlight etc.

Anyway I can do this? the description field will be multiple words, stored as chars.


Some pseudo code

Select * from Product where Description CONTAINS 'keyword'

Any sort of thing that will do contains?
 
SELECT * from product where description LIKE '%keyword%'

SQL = "SELECT * FROM PRODUCT WHERE DESCRIPTION LIKE '%" & strKeyword & "%'"
 
Originally posted by: KLin
SELECT * from product where description LIKE '%keyword%'

SQL = "SELECT * FROM PRODUCT WHERE DESCRIPTION LIKE '%" & strKeyword & "%'"

Like will pick 1 word out of multiple words in a description?
 
Originally posted by: Gobadgrs
Originally posted by: KLin
SELECT * from product where description LIKE '%keyword%'

SQL = "SELECT * FROM PRODUCT WHERE DESCRIPTION LIKE '%" & strKeyword & "%'"

Like will pick 1 word out of multiple words in a description?
Like is a pattern matcher. % acts as a wild card (just like you'd expect * to act normally).
 
Back
Top