Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all ,

In my eCommerce website i have to integrate a search module for products,and the search should be by title,manufacturer,and category.So my question is: Is searching for products using the "like" query is enough ? which means if the user searched by category, i go to the category tables and make the like query and get the results.

Thanks in advance.
Posted

1 solution

Product search By Title and By Manufacture is different from Product search by Categories; because I assume that you would have a list of categories which will be populated from the database (of course not to mention that each category would have an ID associated with it) and Title and Manufacturer can be either the same as follows or be a free text field (like text boxes) to search.

Assuming categories is a list, Title and Manufacturer are free text field, you can do the following

Front End:

Select a category from the list
Type title
Type Manufacturer

Back End
The query would be something like this;

select *
from  dbo.Products 
where categoryID = coalesce((ID from the front end), categoryID)
and   title like '%' + @title + '%'
and   manufacturer like '%' + @manufac + '%'


coalesce keyword is used if the category id is not supplied, it still returns all relevant results.

Hope this helps
Happy Coding :)
 
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