Welcome Guest, Not a member yet? Register   Sign In
print product category and product in the same page

[eluser]Bigil Michael[/eluser]
hi friens
i have 2 tables product category and product

i want to print the result like this

category(no.of product in that category)
eg: laptop(12)

can any one help me to write the query.

thanks in advance....

use following code

$this->db->select('c.category_name, count(p.product_id)');
$this->db->from('tbl_product p');
$this->db->join('tbl_categroy c','p.categroy_id = c.category_id ','left');
$query = $this->db->get();

// SELECT c.category_name, count(p.product_id)
// FROM tbl_product p
// JOIN tbl_category c ON p.category_id = c.category_id
// group by c.category_id

Nasir Ranta

[eluser]Bigil Michael[/eluser]

Theme © iAndrew 2016 - Forum software by © MyBB