Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Using a Query to determine what is left over... wo
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using a Query to determine what is left over... wo

 Post Reply Post Reply
Author
ctytrungloi View Drop Down
Newbie
Newbie


Joined: 09 December 2008
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote ctytrungloi Quote  Post ReplyReply Direct Link To This Post Topic: Using a Query to determine what is left over... wo
    Posted: 02 April 2009 at 3:53am
duc nhom

I may have to find a different way to make this work...

I have three tables: availcabins, weeks & cabinorders

availcabins is a listing of cabins that are available
weeks is a listing of weeks that the camp operates
and cabinorders contains details about which cabins that have been ordered and for what week.

As long as a cabin is made visible and available (1, 0 checkboxes) then it would be available for every week, unless it is already rented, then it wouldn't be available for that week..

Previously in MySQL 4.x this query would give me a listing of cabins that had not been put into an order yet:

Code:

SELECT availcabins.rCabin_name
 , availcabins.rCabin_ID
 , availcabins.rCabin_Wcost
 , availcabins.rCabin_displayOrder
  , cabinorders.cabinOrder_orderID
, weeks.campweek_name
, weeks.campweek_start
, weeks.campweek_length
 FROM ((availcabins LEFT JOIN cabinorders ON cabinorders.cabinOrder_cabinID=availcabins.rCabin_ID)
 RIGHT JOIN weeks ON weeks .campweek_ID=cabinorders.cabinOrder_weekID)
 WHERE availcabins.rCabin_campAvail=1
  AND availcabins.rCabin_visible=1
  AND cabinorders.cabinOrder_orderID is null
  AND weeks.campweek_length<=7
 ORDER BY availcabins.rCabin_displayOrder ASC
, weeks.campweek_start ASC



This query doesn't return the same results in MySQL 5.x.

From what I can tell I need a way to tell the query that every cabin should have every week available, but I don't have a table that does that.

Is there another solution to this without me having join the cottages to the weeks with another table?

Thanks in advance.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.