vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, I am having some trouble joining an additional table for an "advanced search" feature. I have looked around online, checked the mySQL, manual and checked other posts for similar queries, but have had no luck implementing the solutions. Anyways, on the page a user has a few fields where they choose from: - input - search term - dropdown - category - dropdown - author list - date range for the published books * The part I cannot implement is getting the query to search for the terms within the specific category the user has chosen. The table categories_books contains an id of a book and a category to assign it to this category -- this is the part I haven't been able to work into the query yet. Here is my database schema: books ======================= id title author_id slug published etc... categories ======================= id name categories_books ======================= book_id category_id authors ======================= id firstname lastname Here is the query I have so far (without the search within a specific category) For this test query, here are the fields entered book title = 'some book title' author id = 4 published range 1925-1975 SELECT *, MATCH ( b.title ) AGAINST ('some book title' ) AS score FROM books AS b LEFT JOIN authors AS a ON ( b.author_id = a.id ) WHERE MATCH ( b.title ) AGAINST ( 'some book title' IN BOOLEAN MODE ) AND a.id='4' AND b.published <='1975' AND b.published >='1925' ORDER BY score DESC Thank you in advance for any help |