if you are using a select statement, you may need to use tablename.name
Column 'name' in field list is ambiguous with HasManyThrough
I have 3 tables. Let's call them "stores", "categories" and "subcategories".
categories has 3 columns: id, name and store_id
subcategories has 3 columns: id, name and category_id
So, both categories and subcategories have a "name" column.
I'm trying to get all the subcategories related to a store, so I'm using HasManyThrough in the store model:
subcategories() { return $this->hasManyThrough('App\Store\Subcategory', 'App\Store\Category'); }
This make sense, but I'm getting an error:
"Integrity constraint violation: 1052 Column 'name' in field list is ambiguous"
Is there anyway to tell Eloquent I'm only interested in the subcategory name?
Thanks.
Please or to participate in this conversation.