if name and month != '0' and year != '0': cur.execute( '''SELECT * FROM jobs WHERE clientID = (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (name, month, year) ) elif name and year != '0': cur.execute( '''SELECT * FROM jobs WHERE clientID = (SELECT id FROM clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (name, year) ) elif month != '0' and year != '0': cur.execute( '''SELECT * FROM jobs WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (month, year) ) elif year: cur.execute( '''SELECT * FROM jobs WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year )Actually when they contained '0', which is a string which is soemthing and its different from 0 which is like sayif if month is not None.
Problem with and if() logic
Messages In This Thread |
Problem with and if() logic - by nikos - Feb-11-2019, 09:33 PM
RE: Problem with and if() logic - by nilamo - Feb-11-2019, 09:54 PM
RE: Problem with and if() logic - by nikos - Feb-11-2019, 10:14 PM
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Problem in formulating append logic | shantanu97 | 1 | 1,041 |
Jun-07-2022, 08:35 AM Last Post: ibreeden |
|
Number logic problem | m1xzg | 13 | 10,707 |
Oct-23-2016, 09:36 PM Last Post: m1xzg |
Users browsing this thread: 2 Guest(s)