1

enter image description here

i tried with following code but i cant get the attached output

$query = db_select('webform_submitted_data', 'u');
$query->fields('u', array('sid','nid','data'));
$query->condition('nid','49','=');
$results =$query->execute();

echo "<table>";
echo "<tr>";
echo "<th>Name <th>";
echo "<th>Post <th>";
echo "</tr>";
while($record = $results->fetchAssoc())
{
 $sid = $record['sid'];
 $nid = $record['nid'];
$submission = webform_get_submission($nid,$sid);
echo "<tr>";
echo $submission->data[1][0];
echo $submission->data[2][0];
echo "</tr>";
}
echo "</table>";
}
1
  • i tried this distinct() but it is not coming required output as attached output picture Commented Mar 17, 2014 at 10:29

2 Answers 2

1

Try

$query = db_select('webform_submitted_data', 'u');
$query->fields('u', array('sid','nid')); $query->condition('nid','49','=');
$results =$query->distinct()->execute();

Api info about unique

2
  • i tried this distinct() but it is not coming required output Commented Mar 17, 2014 at 10:22
  • try removing 'data' from the fields
    – Attiks
    Commented Mar 17, 2014 at 10:54
0

If you use this query then, its provide proper distinct query.

<?php  

$select = db_select('service_payment_transaction','o');
$select->distinct('o.transaction_id');
$select->innerJoin('users', 'u', 'u.uid = o.user_id');
$select->fields('o');
$select->fields('u');
$select->condition('o.service_gv_code','','!=');
$select->range($start,$page_count);
$select->groupBy('o.service_gv_code');

$select->orderBy('transaction_id', 'DESC'); $result_query = $select->execute();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.