dimanche 26 avril 2020

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`, 
       `product_features`.`id_product` 
FROM   `features` 
       INNER JOIN `product_features` 
               ON `product_features`.`id_feature` = 
                  `features`.`pf_id` 
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:

enter image description here

product_features structure:

enter image description here

features:

enter image description here

Features relation (function from model)

![enter image description here

Thanks for help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire