I have been trying to execute the following query, but it doesn't give me any output.
self.db.execute("SELECT * FROM patients WHERE patients.doctorid = (SELECT id FROM doctors WHERE username = '%s' % (usr)), callback=self.add_response)
I tried to execute the same query by hardcoding the values and it gives me the correct output.
select * from patients where patients.doctorid = (select id from doctors where username = 'admin');
Can someone tell whats the error?
Try to execute it like this:
self.db.execute("SELECT * FROM patients WHERE patients.doctorid = (SELECT id FROM doctors WHERE username = '%s')" % (usr), callback=self.add_response)
I closed the SQL query with "
and fixed the parentheses.
You can also try as shown here:
self.db.execute("SELECT * FROM patients WHERE patients.doctorid = (SELECT id FROM doctors WHERE username = '%s';", (usr), callback=self.add_response)