I am making a program for a school project in laravel, so I am trying to join two tables: products and directions
The Product table has columns: id, name
The Target table has the following columns: Directions: id, product_id, destination, quantity, target_person
and i need to join product_id
andid
products = DB::table('products')
->leftJoin('destinations','id','=','destinations.product_id ')
->get();
but when I try to use LEFT JOIN
, I get the following error:
SQLSTATE [23000]: Violation of integrity constraint: 1052 The column "id" in on is ambiguous (SQL: select * from products
internal connection destinations
on id
= destinations
. product_id
)
source
share