Search engine mechanism with multiple arguments
I am creating a new website using CodeIgniter/PHP/MySQL.
I have the mechanism to pass some items in my database, which has each 3 fields and a description.
Now I want to create a search mechanism for those, with the following features:
- Search for a keyword in both 3 fields and description.
- The user can select multiple values for the 3 fields.
- Combine the above two, if user both selects multiple values and a keyword
I already can parse the data and create something like this:
SELECT * FROM (`My_Table`)
WHERE
`description` COLLATE utf8_general_ci
REGEXP '\[\[:<:\]\]asdasdasd\[\[:开发者_开发知识库>:\]\]'
AND `value1` LIKE '%blabla%'
OR `value1` LIKE 'lala'
but it's far from what I want to create!
I am not expert in SQL, so I am having a hard time to find a way to do this.
If anyone knows/wants, please please help me!! Thanks in advance!
Note: Code samples/Examples will be highly appreciated!
You can use full text search for this
http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html
This will help you alot.
Note: Table should use MyISAM Storage engine and column should be full text indexed.
精彩评论