Try this one i have joined your tables and noticed that DATETIME
field having type text
which is too bad to save the date as text this should be as date
or datetime
but however i have used STR_TO_DATE to convert as date , In below query i have used the left join for mydates
and also used CASE to make custom conditions , you have to provide one date so to get the records of WEEK for that date
SELECT md.`mydate`,
(CASE WHEN g.`ACTION` IS NULL && DAYNAME(md.`mydate`) ='Sunday' THEN 'Weekend'
WHEN g.`ACTION` ='0' THEN g.`ACTIONTEXT`
WHEN g.`ACTION` IS NULL THEN 'holiday'
ELSE 'holiday' END) `action`
,
(CASE WHEN g.`POSITION` IS NULL THEN 'Home' ELSE g.`POSITION` END)`position` ,
g.`DRIVERNAME`,DAYNAME(md.`mydate`),g.`ID` FROM `mydates` md
LEFT JOIN `geoimportroot` g ON (md.`mydate`= STR_TO_DATE(g.`DATETIME`, "%d.%m.%Y") )
WHERE WEEK(md.`mydate`)= WEEK('2013-06-17')
I hope this is what you are looking for