Please, read the question carefully before you mark it as duplicate. It is not.
I have a table named questions, and I have field questionMetaTags in that table which accepts coma separated values (keywords)
Here is my table:
`questionID` int(11) NOT NULL AUTO_INCREMENT,
`questioncategoryID` int(11) NOT NULL,
`questionstatusID` int(11) NOT NULL,
`organizationID` int(11) NOT NULL,
`legalformID` int(11) DEFAULT NULL,
`questionProtocolID` varchar(45) DEFAULT NULL,
`questionDisplayedRecordID` int(11) NOT NULL,
`questionTitle` text NOT NULL,
`questionSummary` text,
`questionText` longtext NOT NULL,
`questionAnswerSummary` text,
`questionAnswerText` longtext,
`questionMetaTags` text,
`questionAskedBy` int(11) NOT NULL,
`questionAnsweredBy` int(11) DEFAULT NULL,
`questionAskedOnDate` datetime NOT NULL,
`questionAnsweredOnDate` datetime DEFAULT NULL,
`questionAskedFromIp` varchar(255) NOT NULL
I am trying to create a query which will "produce" related questions. I am displaying one specific question on my page, and I want bellow to display only the questions that: 1. Belong to same category AND 2. Have at least 2 or more same keywords
In those 2 variables I am holding the category and the keywords of the displayed question, and I would now like to build the query which will display "related" questions.
$keywordsInQurrentQuestion (array that holds the keywords)
$questioncategoryID (category of the question)
I am trying with something like:
SELECT *
FROM question WHERE `questionstatusID` = 5
AND questioncategoryID = $questioncategoryID
// I have no idea how to check if the question have at least 2 keywords that exists in the $keywordsInQurrentQuestion array
");
I have found answers on how to use array in where clause since I want to check for at least 2 same keywords, those answers are not helpful to me.