Need guidance on multiple table query
Posted: Fri May 02, 2008 3:57 pm
I have a query that is looking at four tables
Mx_data
Bikes
Driver
Status
Two of the tables (bikes and Status) have fields with identical name (description). How can I get them both into a recordset? I'm assuming there is someway to set an alias or something like that.
Here's the query
$query_listMx = "SELECT Mx_data.bike_id, Mx_data.Mx_id, Mx_data.rpm, Mx_data.updated, bikes.`description`, driver.`name`, status.`description` FROM Mx_data, bikes, driver, status WHERE bikes.`bike_id`= Mx_data.bike_id AND Mx_data.`driver_id`= driver.driver_id AND Mx_data.`Mx_status` = status.`status_id` AND Mx_data.customer_id = $colname_listMx";
$query_limit_listMx = sprintf("%s LIMIT %d, %d", $query_listMx, $startRow_listMx, $maxRows_listMx);
$listMx = mysql_query($query_limit_listMx, $motorx) or die(mysql_error());
$row_listMx = mysql_fetch_assoc($listMx);
ANy help will be appreciated
Mx_data
Bikes
Driver
Status
Two of the tables (bikes and Status) have fields with identical name (description). How can I get them both into a recordset? I'm assuming there is someway to set an alias or something like that.
Here's the query
$query_listMx = "SELECT Mx_data.bike_id, Mx_data.Mx_id, Mx_data.rpm, Mx_data.updated, bikes.`description`, driver.`name`, status.`description` FROM Mx_data, bikes, driver, status WHERE bikes.`bike_id`= Mx_data.bike_id AND Mx_data.`driver_id`= driver.driver_id AND Mx_data.`Mx_status` = status.`status_id` AND Mx_data.customer_id = $colname_listMx";
$query_limit_listMx = sprintf("%s LIMIT %d, %d", $query_listMx, $startRow_listMx, $maxRows_listMx);
$listMx = mysql_query($query_limit_listMx, $motorx) or die(mysql_error());
$row_listMx = mysql_fetch_assoc($listMx);
ANy help will be appreciated