Records = Cursor.execute("SELECT cust_addr1, cust_addr2, cust_postcode, cust_telno_home, cust_email \ FROM tblcustomer, tblpet \ WHERE cust_surname = ? and tblpet.pet_deceased = ?" ,(SearchCriteria[0], "Y")).fetchall() I can run this query if i remove the tblpet perfectly fine but when i add the tblpet the query runs but i get the results dupliated. So instead of 5 results i had something like 6300 but all of the same results looped.
Thanks
EDIT
I have now fixed it thanks to Mureinik and Siyual for telling me about joins. I then found these
https://msdn.microsoft.com/en-us/library/bb243855(v=office.12).aspx
JOINing mdb tables with pyodbc
It worked 50% bu then i had a great idea of going into access and making the query then switching to SQL view and copying it. It works great and i was so so close
ANSWER
Records = Cursor.execute("""SELECT tblcustomer.cust_addr1, tblcustomer.cust_addr2, tblcustomer.cust_postcode, tblcustomer.cust_telno_home, tblcustomer.cust_email FROM tblcustomer INNER JOIN tblpet ON (tblcustomer.cust_no = tblpet.pet_cust_no) WHERE cust_surname = ? and tblpet.pet_deceased = ?""", (SearchCriteria[0],"Y")).fetchall()
CROSS JOIN. If you intend toJOINthe tables, use the explicitJOINsyntax (don't use commas in theFROMclause - seriously, this was deprecated in 1992) and show how the tables are related in theONclause.