iI want to count select myqad1 where my formid=16the number of submissions where FieldNameformid
is state16
, (that FieldValue= mystate1)state
is and againmystate1
, FieldNameqda
is qdamyqad1
(that FieldValue= myqad1)and again, and FieldNamecity
is city (that FieldValue= mycity1)
inmycity1
.
In my example my, the count is 1 becouse oneshould be SubmissionId1 because only select andSubmissionId
number 2
satisfies all requirements.
$query = $db->getQuery(true);
//$query->select('COUNT(*)');
// hove to count city that is mysity1 and state is mystate1 ??!!!
$query->select($db->quoteName('FieldValue') . ' IN ("mycity1")');
$query->from($db->quoteName('#__rsform_submission_values'));
$query->where($db->quoteName('formid') .' IN ("16")');
$query->where($db->quoteName('FieldName') .' IN ("state","qda","city")');
$query->where($db->quoteName('FieldValue') . ' IN ("mystate1","myqad1","mycity1")');
$db->setQuery($query);
$results = $db->loadObjectList();
foreach($results as $value) {
foreach($value as $key => $data) {
echo $data."<br />";
}
}
Here's a rawmy attempted query, but it doesn't produce the count that I think does what I'm afterwant:
SELECT COUNT(SubmissionId)
FROM my_submission_values
WHERE FormId = '16'
AND FieldName ='state'
AND FieldValue = 'mystate1'
AND FieldName = 'qda'
AND FieldValue = 'myqad1'
AND FieldName = 'city'
AND FieldValue ='mycity1'