2 tables, client_tbl and appt_table, they join using client_id
I'm trying to write a report that will show me:
a) Any clients that have not had an appointment in X amount of time.
This would be done using DATE_SUB(CURDATE(), INTERVAL $time $units) and comparing that against the appointment date in the appt_table.
b) Any clients that have not ever been scheduled for an appointment.
This would be done by finding clients that have no records in the appointment table.
I'm hoping this can be done in one query, but I'm thinking it's not possible. What I have now works only if a client has previously been scheduled (so part a above works), but if a client has never been scheduled, they are not included in the query results.
Any idea how I can select something if it's NOT in another table?
My current SQL is below:
Expand|Select|Wrap|Line Numbers
- SELECT * FROM client_tbl LEFT JOIN appt_table USING (client_id) WHERE appt_table.appt_date_time < DATE_SUB( CURDATE(), INTERVAL 2 week)
Again, I apologize for the double post, but I wasn't getting any takers in the other forum. Mods, please feel free to edit / remove this post if I'm showing bad form.. :)
Greg