Never mind. Trial and error got me there eventually. :)
Still, if anyone has any useful tips about my coding that would be nice.
Here is the working version:
Still, if anyone has any useful tips about my coding that would be nice.
Here is the working version:
mycursor = mydb.cursor() for dfct in defects: if dfct == 0: break # first get the data_id of the latest revision sql = "SELECT * FROM table_def_int_data WHERE defect_id='" + str(dfct) + "' AND revision = (SELECT MAX(revision) from table_def_int_data where defect_id='" + str(dfct) + "')" mycursor.execute(sql) myresult = mycursor.fetchone() sql = "SELECT * FROM table_def_int_data WHERE defect_id='" + str(dfct) + "' AND data_id = " + str(myresult[0]) mycursor.execute(sql) myresult = mycursor.fetchone() print(myresult) mycursor.close()