Go Back   SitePoint Forums > Forum Index > Program Your Site > Databases > MySQL
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Feb 27, 2006, 11:49   #1
Justin Sampson
Not Bad, eh?
 
Justin Sampson's Avatar
 
Join Date: Aug 2000
Location: N.S., Canada
Posts: 584
I need some kind of Join, that's my best guess...

Hello everyone,
I have a table that looks like this:

Seasons:

seasonID
seasonPID
seasonFromdate
seasonTodate
seasonNightlyPrice
seasonWeeklyPrice
seasonMonthlyPrice
seasonWeekendPrice

...and another table like this:

Cottages:

cotID
cotName
cotAddress

The "seasonPID" field corresponds to the "cotID" of the records in Cottages table.

Now what I want to do is run a query that will list the records in the cottage table by price, and that data is found in the Seasons table. The catch is, that:

A). Each cottage can have from 0 to 5 seasons (each season is an entry in the Seasons table), and I want to make sure I order by the price of the current season (that what the From and To fields are for, they are the start and end dates). Also, if there are no records in the Seasons table, the cottage should be displayed at the end (instead of at the start with a price of $0)

B). A season might have just one, or all of the Prices inputed (prices are inputed for Nightly, Weekly, Monthly, and Weekend). I want the query to take whichever is lowest (other then $0) and use that to order the results. So if one cottages current season has a nightly price of $80, and another cottage has a weekend price of $70, the one that is $70 would be displayed first. What I'm trying to say is that not all records need to ordered by the same price field, simply whatever price is lowest.

Any input would be great, because I have no idea where to start.

Best regards,
Justin
Justin Sampson is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 00:34.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved