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_id
FROMarticle
WHEREarticle
.is_active
= '1' AND (content
LIKE '%%' ORtitle
LIKE '%%' ORtags
LIKE '%%') UNION ALL SELECTarticle
.article_id
FROMkeywords
INNER JOINarticle
WHEREarticle
.is_active
= '1' AND (article
.article_id
=keywords
.article_id
ANDkeywords
.keywordtext
LIKE '%%')
TABLE article
COLUMNS
article_id
(PRIMARY)is_active
title
themonth
theyear
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_id
article_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_id
categories_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_id
read_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_id
keywordtext
Hope! I've formatted it correctly so everyone can understand!