Question: I'm getting a product listing. Each product may have 1 or more image, I only want to return the first image.

```
$this->db->select('p.product_id, p.product_name i.img_name, i.img_ext');    
$this->db->join('products_images i', 'i.product_id = p.product_id', 'left');
$query = $this->db->get('products p');

```

Is there anyway to limit the db->join to 1 record using the CI active record class?

Answer: 
Add `$this->db->limit(1);` before calling `$this->db->get('products p');`. See the docs at [ellislab.com](http://ellislab.com/codeigniter/user-guide/database/active_record.html): search the page for **limit**.

EDIT: I misread the fact that you were trying to apply the LIMIT to the internal JOIN statement. 

No. Since you can not do a LIMIT on an internal JOIN statement in regular SQL you can not do it with Code Igniter's ActiveRecord class.
You can achieve what you want using `$this->db->group_by` with a `left` join:

```
$this->db->select('products.id, products.product_name, products_images.img_name, products_images.img_ext');
$this->db->from('products');
$this->db->join('products_images', 'products_images.product_id = products.id', 'left');
$this->db->group_by('products.id'); 
$query = $this->db->get();

```

This should give you results by `products.id` (without repetition of products), with the first matching record from `products_images` joined to each result row. If there's no matching row from the joined table (i.e. if an image is missing) you'll get null values for the products\_images fields but will still see a result from the `products` table.