Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.