sniperscope Posted April 11, 2012 Share Posted April 11, 2012 Hello I have a little problem with left join(yet again) I want to get all staff name and staff working time. My staff table is: | id | staff_name | +-----+----------------+ | 1 | Michael | | 2 | Jason | And schedule table is: | id | staff_id | start_time | end_time | days | +-----+-----------+--------------+--------------+-------+ | 1 | 1 | 14:00 | 15:00 | 1334070000 | 2 | 1 | 20:00 | 23:00 | 1334072000 | 3 | 2 | 20:00 | 23:00 | 1334075000 | 4 | 2 | 20:00 | 23:00 | 1334076000 | 5 | 2 | 20:00 | 23:00 | 1334077000 | 6 | 1 | 20:00 | 23:00 | 1334078000 | 7 | 2 | 20:00 | 23:00 | 1334078000 | 8 | 1 | 20:00 | 23:00 | 1334080000 | 9 | 1 | 20:00 | 23:00 | 1334080000 I am running this query but it return 0 SELECT g.staff_name, s.start_time, s.end_time FROM staff_master g LEFT JOIN schedule s ON g.id = s.staff_id WHERE s.days >= '1334070000' ORDER BY s.days ASC What am i trying is to get all staff names and their one week working schedule. If they are working (lets say) thursday then get his/her start and end time else just echo 00:00 Regards Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 11, 2012 Share Posted April 11, 2012 and the problem is what? you only get back the days the actualy worked? Quote Link to comment Share on other sites More sharing options...
sniperscope Posted April 11, 2012 Author Share Posted April 11, 2012 I want all person name regardless they are working or not. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 11, 2012 Share Posted April 11, 2012 Yeah, the question marks are me asking a question. What's the actual problem problem? What does your query do just now? I'm only assuming from having a glance that's what's happening, I'm not going to spend time providing a solution to a problem that may not even be related to what you are experiencing. Quote Link to comment Share on other sites More sharing options...
sniperscope Posted April 11, 2012 Author Share Posted April 11, 2012 Then please do NOT spend time providing a solution. Thanks for interesting anyway. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.