Here again Keith Medcalf, when I try in my project, I face a problem. I cannot make it to working. I have 4 tables: (1) Daily_Transaction (2) cogs (3) goods (4) user CREATE TABLE "cogs" ( "cogs_id" INTEGER UNIQUE, "VAT" INTEGER, "GST" INTEGER, "other_taxes" INTEGER, "labor_cost" INTEGER, "transportation_cost" INTEGER, "surcharge" INTEGER, PRIMARY KEY("cogs_id" AUTOINCREMENT) ); A button_1 confirms: conn = sqlite3.connect('dawr.db') c = conn.cursor() VAT = self.txt_vat.text() #GST = int(self.txt_gst.text()) GST = self.txt_gst.text() other_taxes = self.txt_other_tax.text() labor_cost = self.txt_labor_cost.text() transportation_cost = self.txt_transport_cost.text() surcharge = self.txt_surcharge.text() c.execute( "INSERT INTO cogs(VAT, GST, other_taxes, labor_cost, transportation_cost, surcharge) VALUES (?,?,?,?,?,?)", (VAT, GST, other_taxes, labor_cost, transportation_cost, surcharge)) conn.commit() conn.close() It worked. The other table: CREATE TABLE "goods" ( "reference" INTEGER, "item_id" INTEGER NOT NULL UNIQUE, "item_name" TEXT NOT NULL UNIQUE, "item_code" TEXT UNIQUE, "item_description" TEXT, "purchase_date" TEXT, "quantity" INTEGER NOT NULL, PRIMARY KEY("item_id" AUTOINCREMENT) ); Now, the button_2 (here is my problem) conn = sqlite3.connect('dawr.db') c = conn.cursor() itemName = self.lineEdit_3.text() itemDesc = self.lineEdit_6.text() itemCode = self.lineEdit_11.text() itemCP = self.txt_cost_price.text() itemQnty = self.txt_quantity.text() c.execute("INSERT INTO goods select max(cogs_id), ?, ?, ?, ?, ?, ?, ? from cogs", (itemName, itemDesc, itemCode, itemCP, itemQnty)) conn.commit() conn.close() self.label_5.setText("<font color='red'>You've successfully records item. Please continue adding more item " "until you finish.</font>") I want to insert into reference column in goods table the value of cogs_id from table cogs. I cannot point out my mistake and couldn't solve all alone. (I am a self learner.) Could you please help me out again?