Hey so I have a question. I have two tables. table1 and table2. table1:
id | car_numbers | type | model | type_id
1 3 bmw <model1> 1
2 5 bmw <model2> 1
3 2 mercedes <model1> 2
4 4 mercedes <model2> 2
5 1 chevrolet <model1> 3
table2:
id | price | type_id
1 100 1
2 200 1
3 300 2
4 400 2
5 500 3
What I want, is to display the 'type', the 'car_numbers' and the average price of each car type. Basically the result of what I want between those two tables is:
type | car_numbers | average_price
bmw 8 150
mercedes 6 350
chevrolet 1 500
How can I do that? I know I have to relate to the type_id that's common in both tables but how can I do that?
joinquery with agroup by. You should know these basic constructs in MySQL if you are using the database.average price?