0
$sql = "SELECT COUNT( '1' ) AS `num`
        FROM `tbl_product`
        WHERE `cat_id` =$cat_id
        AND `product_status` =1";

Here:

$cat_id = 1
product_status = 1= active

In the Above Code i can get the num as 7 as there are 7 products based on cat_id

$sqi = "SELECT COUNT( '1' ) AS `num` *
        FROM tbl_cat
        JOIN tbl_product ON tbl_cat.cat_id = tbl_product.cat_id
        AND product_name LIKE '%$similar%'
        AND cat_name LIKE '%$field%'"

Here:

cat_id=1
$similar = input value
$field = cat_id(Value)

But in the above query i cannot get the num as 7 as i'm using search button So can any one help me on this.

Thank You!

rocky
  • 5
  • 2
  • 2
    You should really have a read of this (really long) Q&A that I wrote for just an instance like this: http://stackoverflow.com/questions/12475850/how-can-an-sql-query-return-data-from-multiple-tables – Fluffeh Mar 20 '14 at 10:49
  • Thank You for the guidance.... most helpful! – rocky Mar 20 '14 at 10:54

0 Answers0