0

Mysql Query :

SELECT SUM(`Item_qty`), `bill_id`,`Item_name`,`table_id`,`Item_price` 
FROM tbl_billmenu 
WHERE `table_id` = 30 
GROUP BY `Item_name`

How should I've to code/implement this above query in codeigniter module ? please help

2

1 Answer 1

1

This is how you do it:

 $this->db->select(bill_id,Item_name,table_id,Item_price,sum(Item_qty) as quantity);
    $this->db->where('table_id', 30);
    $query = $this->db->get('tbl_billmenu');
Sign up to request clarification or add additional context in comments.

1 Comment

@Swap This query is invalid GROUP BY you can't mix a non aggregate columns with a aggregate column.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.