feri_soft Posted October 15, 2006 Share Posted October 15, 2006 How to create a keywords search which can search 1 in the title, 2 in the description.Please help,desperately need a solution. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/ Share on other sites More sharing options...
dymon Posted October 15, 2006 Share Posted October 15, 2006 Provide please more details about the search. Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-108982 Share on other sites More sharing options...
Barand Posted October 15, 2006 Share Posted October 15, 2006 SELECT * FROM tablenameWHERE (title LIKE '%$keyword%')OR (description LIKE '%$keyword%') Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-109011 Share on other sites More sharing options...
Daniel0 Posted October 15, 2006 Share Posted October 15, 2006 To do Google-like searching ("bla3 bla1" -bla2 +bla3) you may use fulltext searching: [code]SELECT * FROM tablename WHERE MATCH (title,body) AGAINST ('"bla3 bla1" -bla2 +bla3' IN BOOLEAN MODE);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-109015 Share on other sites More sharing options...
feri_soft Posted October 18, 2006 Author Share Posted October 18, 2006 Bernard are you sure that SELECT * FROM tablenameWHERE (title LIKE '%$keyword%')OR (description LIKE '%$keyword%') will find exactly the matches...because i dont want unneeded results. Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-110768 Share on other sites More sharing options...
alpine Posted October 18, 2006 Share Posted October 18, 2006 To find exact matches, remove the percentage signs:[code]<?phpSELECT * FROM tablename WHERE (title LIKE '$keyword') OR (description LIKE '$keyword') // exact matchSELECT * FROM tablename WHERE (title LIKE '%$keyword%') OR (description LIKE '%$keyword%') // match somewhere inSELECT * FROM tablename WHERE (title LIKE '$keyword%') OR (description LIKE '$keyword%') // exact match on "starting with"SELECT * FROM tablename WHERE (title LIKE '%$keyword') OR (description LIKE '%$keyword') // exact match on "ending with"?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-110783 Share on other sites More sharing options...
feri_soft Posted October 18, 2006 Author Share Posted October 18, 2006 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-110810 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.