I want to implement a search function in my application based on these tables.
I have 5 fields on search page
- Input box - Keywords or any word in the title
- Author - Select Box (author_id will be passed to the function as value)
- Category Name - Select Box (category_id will be passed to the function as value)
- themonth - Select Box from 1 - 12
- theyear - Select Box from 2000 - 2012
I want to create a search query from based upon these rules,
- Results array will be sorted by
insights.read_time, (how many times the article has been read) - Only want to get the
article.article_id
Pre-mature working working example is here
I am running following query to get but it is not complete https://leading-people.com/search
SELECT
article.article_idFROMarticleWHEREarticle.is_active= '1' AND (contentLIKE '%%' ORtitleLIKE '%%' ORtagsLIKE '%%') UNION ALL SELECTarticle.article_idFROMkeywordsINNER JOINarticleWHEREarticle.is_active= '1' AND (article.article_id=keywords.article_idANDkeywords.keywordtextLIKE '%%')
TABLE article
COLUMNS
article_id(PRIMARY)is_activetitlethemonththeyear
TABLE article_author
Comments: This table is just for reference author details is in another table. So these id(s) are just for reference.
COLUMNS
article_author_id(PRIMARY)author_idarticle_id
TABLE article_categories
Comments: This table is just for reference categories details is in another table. So these id(s) are just for reference.
COLUMNS
article_categories_id(PRIMARY)article_idcategories_id
TABLE insights
Comments: This table is just for reference categories details is in another table. So these id(s) are just for reference.
COLUMNS
insights_id(PRIMARY)article_idread_time
TABLE keyword
Comments: This table is just for reference categories details is in another table. So these id(s) are just for reference.
COLUMNS
keyword_id(PRIMARY)article_idkeywordtext
Hope! I've formatted it correctly so everyone can understand!