Im wondering if its possible to do what I want to do all in one query - Im guessing it is because i dont think its that complicated but its too complicated for me to figure out anytime soon.
I've got two tables, equipment and services:
Each equipment may have several services, and these services might be past services or upcoming services. There is a column in the services table `upcoming` which if set to 1 tells you that it is an upcoming service and if 0 a past service.
I want to select all from equipment, and along with each row select the date of last service and the date of the next upcoming service.
Bear in mind though that a certain equipment may not have any past services or it may not have any upcoming services.
`equipmentid`, `name`, `otherdetails`
`serviceid`, `equipmentid`, `date`, `service_description`,`upcoming`