Does Datatable supports Group By query?

Does Datatable supports Group By query?

ayxaayxa Posts: 8Questions: 4Answers: 0

Hi, I was trying to group columns with same values in a row. But I am facing some issues where when I try to group query Datatable doesn't works. Just showing data but no other functionality is working.

$query .= "SELECT *, count(*) as count, product.product_id, product.shop_id, shop.shop_id, shop.shop_name
    FROM product
INNER JOIN shop ON product.product_id = shop.shop_id 
GROUP BY shop.shop_id HAVING COUNT(*) >= 1;";

if (isset($_POST["search"]["value"])) {
    $query .= 'WHERE shop.shop_id LIKE "%' . $_POST["search"]["value"] . '%" ';
    $query .= 'OR shop.shop_name LIKE "%' . $_POST["search"]["value"] . '%" ';
    $query .= 'OR product.product_name LIKE "%' . $_POST["search"]["value"] . '%" ';
}

if (isset($_POST['order'])) {
    $query .= 'ORDER BY ' . $_POST['order']['0']['column'] . ' ' . $_POST['order']['0']['dir'] . ' ';
} else {
    $query .= 'ORDER BY shop.shop_name ASC ';
}

if ($_POST['length'] != -1) {
    $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}

I tried what ever I knew. Any suggestion will be so much helpful. Thanks :smile:

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    , I was trying to group columns with same values in a row.

    I'm not clear what you mean by grouping columns. You can group rows with RowGroup - could you give more information please.

    Colin

  • ayxaayxa Posts: 8Questions: 4Answers: 0

    I want group rows those have same values in one

This discussion has been closed.