SELECT rows with latest upload time per category using CodeIgniter's query builder
12:49 03 Sep 2012

I am trying to find out the latest image uploaded in each of the categories of a website from the database where the structure of the database is:

tbl_cat:

  • cat_id,
  • cat_name,
  • noi (no. of total images in that cat)

tbl_img:

  • img_id,
  • cat_id, img_path,
  • imag_caption

Any idea how can I do it using query builder methods? I would also love to understand it with a raw SQL query.

php mysql codeigniter group-by query-builder