I am trying to enter my horse in a race but all I get is
racequery: 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 ‘AND h.Leased = 0) OR (l.Leaser = AND h.Leased = 1 AND l.Start <= ‘2015-04-14’)’ at line 13
SELECT r.ID, r.Date, r.Num, t.Name AS Track, rt.Type, r.Name, rg.Grade, ra.Age, r.Distance, t.DTSC, r.Purse, r.Gender, rg.Abbr, COUNT(re.Horse) AS Entries FROM ff_races r LEFT JOIN ff_nomraces nr ON r.ID = nr.Race LEFT JOIN ff_trackdata t ON r.Location = t.ID LEFT JOIN ff_race_types rt ON r.Type = rt.ID LEFT JOIN ff_race_grades rg ON r.Grade = rg.ID LEFT JOIN ff_race_ages ra ON r.Age = ra.ID LEFT JOIN ff_raceentries re ON r.ID = re.Race LEFT JOIN ff_horses h ON re.Horse = h.ID LEFT JOIN ff_leases l ON l.Horse = h.ID WHERE r.Date > ‘2015-04-14’ AND r.Date <= ‘2015-05-14’ AND r.ID IS NOT NULL AND nr.Race IS NULL AND (((h.Owner = AND h.Leased = 0) OR (l.Leaser = AND h.Leased = 1 AND l.Start <= ‘2015-04-14’)) OR re.Horse IS NULL) AND (r.Gender != ‘F’ OR r.Gender IS NULL) AND (ra.Age LIKE ‘%+’ OR ra.Age LIKE ‘%4%’) AND (rt.Type = ‘Allowance’ OR rg.Grade = ‘Ungraded’ OR rg.Grade = ‘Grade 3’ OR rg.Grade = ‘Grade 2’ OR rg.Grade = ‘Grade 1’) GROUP BY r.ID ORDER BY r.Date, Track, r.Type
What can I do?