Soldato
MySQL data - Severe brain fart day
Hi All,
I have a simple staff booking table where everytime a staff member is 'out' it gets logged (B_ID is the primary key and auto incremented, and staff can have multiple entries for the same date), like so -
I basically need to return a list of any Staff member that haven't been 'out' for the last 6 months but i'm having a seriously bad case of brain farts today.
So far i can return the last booking of a specific staff -
But I'm being completely dense it grabbing a list of all Staff IDs that have a last known booking date (B_DATE) older than 6 months.
Edit - Think i've sorted it by using the HAVING clause.
Hi All,
I have a simple staff booking table where everytime a staff member is 'out' it gets logged (B_ID is the primary key and auto incremented, and staff can have multiple entries for the same date), like so -
Code:
B_ID | B_Date | Staff_ID
-----|------------|----------
1 2012-02-20 10
2 2012-02-20 11
3 2012-03-20 11
I basically need to return a list of any Staff member that haven't been 'out' for the last 6 months but i'm having a seriously bad case of brain farts today.
So far i can return the last booking of a specific staff -
Code:
SELECT b2.`Staff_ID` , b2.`B_Date`
FROM `bookings` b2
WHERE b2.`Staff_ID` = 11
ORDER BY b2.`B_Date` DESC
LIMIT 1
But I'm being completely dense it grabbing a list of all Staff IDs that have a last known booking date (B_DATE) older than 6 months.
Edit - Think i've sorted it by using the HAVING clause.
Last edited: