Python Forum
Problem in DB requests using if()s
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem in DB requests using if()s
#5
This does not work well some parts of if work and some others don't:

		if name and month.isdigit() and year.isdigit():
			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.isdigit():
			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.isdigit() and year.isdigit():
			cur.execute( '''SELECT * FROM jobs WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (month, year) )

		elif year.isdigit():
			cur.execute( '''SELECT * FROM jobs WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year )
Please helpe me write it correctly and simply.
Reply


Messages In This Thread
Problem in DB requests using if()s - by nikos - Feb-09-2019, 06:06 PM
RE: Problem in DB requests using if()s - by woooee - Feb-09-2019, 06:35 PM
RE: Problem in DB requests using if()s - by nikos - Feb-09-2019, 07:33 PM
RE: Problem in DB requests using if()s - by nikos - Feb-09-2019, 11:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Import requests/beautifulsoup problem Jokadaro_ 3 2,137 Dec-05-2021, 01:22 PM
Last Post: Jokadaro_
  Requests problem ZarKx 3 3,424 May-22-2018, 12:22 PM
Last Post: ZarKx

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020