Feb-02-2019, 03:00 PM
i believe it would be something along the lines of this
if '=' not in year: cur.execute( '''SELECT * FROM jobs WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year ) elif '=' not in month: cur.execute( '''SELECT * FROM jobs WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (month, year) ) elif '=' not in name: cur.execute( '''SELECT * FROM jobs WHERE clientID = (SELECT id FROM clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (name, year) )although the first selection is not used because its condition is repetetive...and you didnt post the else clause
Recommended Tutorials: