Jump to content

Left Join not grabbing data


sniperscope

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/260720-left-join-not-grabbing-data/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.