MySQL Forums
Forum List  »  Newbie

Query problem
Posted by: drbytes
Date: April 05, 2006 12:40PM

Hi,

I'm a bit stomped with something I would like to do in mysql, but not sure how I should do it.
Perhaps it's not even possible, I'll try to explain.
I have two tables, Rents and Vechicules.
In the Rents table I have these fields, CustomerId, startdate, enddate, vechicleId as int, date, date, int resp.
The Vechicules table contains the fields VechiculeId and licenseplate.

So there's a link from the Rents to the vechicules table with vechiculeId.
With this i could see which customer has which car in a certain start to end date,
but also, because there's a carpooling scheme and insurances we can have 2 or more customers renting the same car.

And I want to be able to search in the Rents table with the Customer id, a start date and an endate and return all the rows where that certain customer is the sole renter.
No with the carpool we would have in the Rents table:
2 - 04/04/06 - 04/11/06 - 6
3 - 04/04/06 - 04/31/06 - 6


So customers 2 and 3 are carpooling from 04/04 to 04/11 and then after that customer 3 is the sole renter from 04/15 until 04/31.

Long dragged out question, can someone help out with this query? I really don't know whether it even possible with mysql.

Cheers

Options: ReplyQuote


Subject
Written By
Posted
Query problem
April 05, 2006 12:40PM
April 06, 2006 07:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.