|
Query: select tr.day, DATE_FORMAT(d.date,'%d/%m/%Y') as date,
summa, balance, text, IF(m2.id > 0, IFNULL(mh1.manager, '---'), IFNULL(mh.manager, '---')) as manager,
IF(m2.id > 0, IFNULL(m1.id, 0), IFNULL(m.id, 0)) as id
from transactions tr, days d
left join manager_histories mh
on mh.team = '520'
and d.date >= mh.date_start
and d.date <= mh.date_end
left join manager_histories mh1
on mh1.team = '520'
and d.date >= mh1.date_start
and (d.date <= mh1.date_end or mh1.date_end = '0000-00-00')
left join managers m on mh.manager = m.name
left join managers m1 on mh1.manager = m1.name
left join managers m2 on m2.team = '520'
where tr.team = '520' and tr.day = d.day
order by tr.day desc, tr.id desc
limit -200, 50 error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-200, 50' at line 18 |