Ambiguous column name laravel 5.6+

i have a problem with error called “Column ‘id’ in field list is ambiguous”.

I’ve tried to fix it by using aliases on columns but i had no luck in fixing it. Query looks like this:

SELECT `id`               AS `pf_id`, 
`id_feature` AS `pf_if`,
`id_feature_value` AS `pf_ifv`,
FROM `features`
INNER JOIN `product_features`
ON `product_features`.`id_feature` =
WHERE `product_features`.`id_product` IN (
33003, 33004, 33011, 33012,
33013, 33015, 33016, 33017,
33018, 33019, 33020, 33021,
33022, 33023, 33024, 33025,
33026, 33029, 33030, 33032 )
AND `id_feature` = 5

Id is used only in select and inner join. It’s calling product_features table and features table. Only this pice of code is not working – any other relation on product is working fine. Below are additional info about table structure plus relation:

$products = Product::select('id', 'id as DT_RowId', 'id_manufacturer', 'sku', 'price_retail', 'active')
'manufacturer' => function ($m) {
$m->with(['defaultTranslation' => function ($query) {
$query->select('id', 'id_manufacturer', 'name');
'defaultTranslation' => function ($dt) {
$dt->select('id', 'id_product', 'name');
'features' => function ($qf) {
$qf->select('id as pf_id', 'id_feature as pf_if', 'id_feature_value as pf_ifv');
$qf->where('id_feature', 5);

$result = $products->orderBy('id', 'DESC')->paginate($itemNumber, ['*'], 'page', $page);

product_features structure:

enter image description here


enter image description here

Features relation (function from model)

public function features()
return $this->hasManyThrough('AppSupremeShopModelsFeature',

Thanks for help!

from Newest questions tagged laravel-5 – Stack Overflow

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.