Hi,
I have a 'complex' SQL query on two mysql tables which I
need to join.
One contains RENTAL AGREEMENT DATA and the other REAL
ESTATE DATA. I
need to join the two tables to see which APARTMENTS are not
rented out
for the current month.
Important is
1. I need to SELECT property_id from the REAL
ESTATE DATA TABLE
2. In the RENTAL AGREEMENT TABLE rental_start_date >
current month OR
status in RENTAL AGREEMENT TABLE is INACTIVE
problem is that an apartment might have had 10 RENTAL
AGREEMENTS over
the past 10 years meaning it has many entries with
rental_start_date
and rental_end_date. I need to do a DISTINCT select and that
on the
last RENTAL AGREEMENT??
It is also possible that an apartment never had a RENTAL
AGREEMENT and
this apartment should also appear in the sql result.
Regards
Leon
`rental_agreement_data`
`rental_agreements_id`
`property_id`
`tenant_id`
`start_date
`end_date`
`real_estate_data`
`property_id`
`street`,
`address1`
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|