I am trying to find the best way to perform a onditional query on a table that is looking like this:
primaryKey question answer clientId
1 are you fine? yes Bob
2 are you fine? no Tom
3 what is your name Bob Bob
4 What is your name Tom Tom
WHERE clientId IN(
SELECT clientId FROM `questionTable`
WHERE (question = "are you fine" AND answer = "yes")
AND question = "What is your name"
Use a self join the table:
SELECT t1.primaryKey FROM `questionTable` t1 INNER JOIN `questionTable` t2 ON t1.clientId = t2.clientId WHERE t2.question = "are you fine?" AND t2.answer = "yes" AND t1.question = "What is your name"