Tuesday 4 September 2018

MySQL Count Query does not work but its list of display records

I try to use this Query to get Number of Records bu tits not display count in phpMyAdmin

And also give me the wrong result when i try to remove LIMIT from Query..
  SELECT COUNT(*) as `num` FROM fm_detail
  LEFT JOIN lang ON lang.l_id = fm_detail.language_id
  LEFT JOIN country ON country.c_id = fm_detail.country_id
  LEFT JOIN users ON users.usr_id = fm_detail.submitter_id
  LEFT JOIN category ON category.cat_id = fm_detail.category_id
  INNER JOIN city ON fm_detail.city_fm = city.city_id
  where 1=1 AND fm_detail.category_id = '1' LIMIT 10 , 5

This query did not give me any Record Count..
But when i use..
  SELECT * FROM fm_detail
  LEFT JOIN lang ON lang.l_id = fm_detail.language_id
  LEFT JOIN country ON country.c_id = fm_detail.country_id
  LEFT JOIN users ON users.usr_id = fm_detail.submitter_id
  LEFT JOIN category ON category.cat_id = fm_detail.category_id
  INNER JOIN city ON fm_detail.city_fm = city.city_id
  where 1=1 AND fm_detail.category_id = '1' LIMIT 10 , 5

This give me the Records list in PHPMYADMIN..
I don't know how to use this query to fix my problem.
Please help me asap..
Thanks,

Because you use COUNT function (which in your case returns one row) and LIMIT clause that starts from 10 record. So, you do not get any records at all.

0 comments:

Post a Comment