sashi34u Posted June 16, 2009 Share Posted June 16, 2009 Hi, I have been trying to use an inner join and outer join command at a time in a query. But, It is not working properly. I believe that my syntax is wrong. Can anyone please help me in this matter. I am posting the query below. Actually this query is being used in PHP. So please ignore the variables. To explain a little bit, the table IMAGE does not have entries to all the building codes in the table Buildings. That is the reason I wanted to use an outer join. Thanks, Sashi SELECT Location FROM Image LEFT JOIN Buildings ON Image.bldcode=Buildings.BuildingCode buildingname, parking_lot_name, (FS+COM+RES+FS_COM+VISITOR+GEN) AS total_spaces, (TIMED+METER) AS Metered, empty_spaces, distance, round(distance/($low_speed*60),1) AS low_time, round(distance/($high_speed*60),1) AS high_time FROM buildings, buildings_lots, parkinglots, occupancy where ( buildings.buildingcode=buildings_lots.building_code AND parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND parkinglots.parking_lot_code=occupancy.parking_lot) AND buildingname='$build' AND month='$Month' AND day='$Today' AND Time='$times' ORDER BY Distance Link to comment https://forums.phpfreaks.com/topic/162450-using-inner-join-and-outer-join-at-a-time/ Share on other sites More sharing options...
kickstart Posted June 16, 2009 Share Posted June 16, 2009 Hi Trying to look at the query but it appears that you have a lot of the fields you want to select mixed into the FROM clauses. Normally you can mix them easily. For example, say you have a list of building lots, a list of buildings for each lot, and each building may have an image record (very roughly what I think you are describing):- SELECT a.buildingLotNumber, a.buildingLotAddr, b.buildingName, b.buildingBuyer, c.imageName FROM buildings_lots a JOIN buildings b ON a.buildingcode = b.buildingcode LEFT OUTER JOIN image c ON b.BuildingCode = c.bldcode All the best Keith Link to comment https://forums.phpfreaks.com/topic/162450-using-inner-join-and-outer-join-at-a-time/#findComment-857502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.