I am using following query to search product names for the keywords submitted by customers. select * FROM tblproducts WHERE prodName LIKE lower('%$keyword%') Code (markup): I have product name in db "Crib Green" When i provide keyword "crib green" query returns one row.Its perfect. When i search for "Green Crib" search result is zero row selected. I want that MySQL should return "Crib Green" whether I search "crib green" or "green crib" How? Please help. Thanks
you should do a query like ALTER TABLE tblproducts ADD FULLTEXT(prodName); select * FROM tblproducts WHERE match (prodName) against ($keyword)
select * FROM tblproducts WHERE prodName (LIKE lower('%$keyword1%')) AND (LIKE lower('%$keyword2%')) You should split you search request into seperate items and offer them this way. P.S. Using crivion's suggestion is usually beter since the responsibility for searching is left to the database server instead of doing it yourself.