Inner join in tables 1 - n

1

I have two tables: Vehicle and Images, where a vehicle can have n images. When performing an inner join I get the following result: Vehicle1-Endereco picture Vehicle1-Endereco picture Vehicle2-Endereco picture Vehicle2-Endereco picture Vehicle2-Endereco picture I wonder if there is any way to get the results this way: V1-All Images of the Vehicle1 V2-All Vehicle Images2

I am developing a project in asp net mvc and would like to send this last result to my view. There is something I can do to get the data this way.

    
asked by anonymous 10.09.2017 / 07:41

1 answer

1

From what I understand, this is just an ordering problem?

If all vehicles have at least one image, a inner join must be used and at the end of the query a order by by the id / name / etc of the vehicle.

If a vehicle may not have an image, then left join should be used to pick up unimagined vehicles. Here would also use a order by by id / name / etc of the vehicle.

I hope I have helped.

    
10.09.2017 / 11:42