Help needed with complex mysql queries on a property website