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. :-\ 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. 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%') 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] 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. 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] 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 Link to comment https://forums.phpfreaks.com/topic/23987-keyword-search/#findComment-110810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.