How to update the foreign key value of table 2 from the primary key of table 1

64
November 16, 2019, at 5:50 PM

Currently, I have 2 tables which table 1 has the primary key of customer_id and table 2 has the foreign key of customer_id. My issue is, I tried to update the value of the foreign key from the value of primary key, but the value is always 0 for foreign key, even thought primary key is 1.

Images for table 1:

Image for table 2:

Based on my image you can see that I am trying to make the value of my primary key and foreign key to be the same but I can't seem to get it right.

My code:

UPDATE customer_payment_information 
SET customer_id = (
    SELECT customer_id 
    FROM p2_5.customer_information 
    ORDER BY customer_id DESC LIMIT 1
) 
ORDER BY customer_id DESC LIMIT 1;
READ ALSO
loading data into combo object with sql query result in Java

loading data into combo object with sql query result in Java

I would like to load a combo object with a result of sql queryI do not know how to convert List into String[]

54