MYSQL select statement, 2 fields with same name in different table
Posted on 2008-06-14
I have 2 tables:
Car and Car_Make
In Car I have 2 fields, car_make and car_model, both are int.
In Car_Make I have 2 fields, make_id and make_name
I want to be able to use my select statement to select all the cars in the Car table, however I need the make and model name from the car_make table.
I don't know how to write the statement, since the make_name field has both of the fields I need.
Here is a sample select to start with, that just selects the int values:
$query1 = "SELECT car_model, car_make, car_year, car_price, car_mileage, car_avail FROM site_cars ORDER BY $sortby";