Repeating the comments of others. You should probably normalize your model.
However, it is impossible to extract the required result, just to make the solution ineffective and not scalable, for new developers difficult to understand and not very extensible.
In addition, it is easier to extract data in a long format rather than in a wide format, i.e.
against.
Converting from long to wide is easier in php (and might not even be required).
SELECT CONCAT(pr.qno, ":", pr.paid_response) dimension, COUNT(*) `count` FROM lead_submission ls JOIN paid_response pr ON ls.qa_details LIKE CONCAT("%", pr.qno, ":", pr.paid_response, "%")
In the above query, where clause should be the same for both selected ones, and I think for your case it should look like this:
WHERE CONCAT(pr.qno, ":", pr.paid_response) IN (<key-value pair 1>, <key-value pair 2>, ...)
This returns the following result:
DIMENSION COUNT 1083:No 1 504:Yes 2 count-agent 2
Here sqlfiddle demo
Haleemur ali
source share