I would like bring in data from one table to another. I have two tables, “Calendar1” and “Calendar2”, these two tables are joined on the field “ID1” “ID2” (I do not know if the joined relationship is correct. I would like to copy information from the field “Event1” in Calendar1 to “Event2” in Calendar in those cases where “event2” has currently no data. I have tried this UPDATE “Calendar2” SET “Event2”= “Calendar1”.“Event1” WHERE “Calendar2”.“Event2”=NULL This doesnt work.
Even if I simplify the command and say UPDATE “Calendar2” SET “Event2”= “Calendar1”.“Event1” I get the message Column not found: Calendar1.Event1 .
Any ideas. Maybe something is wrong with the relationship in which I have chosen “update cascade”.
There are a few things wrong with your statement. The statement doesn’t know where the field "Calendar1"."Event1"
is coming from. Next it doesn’t know what records from “Calendar1” it should get “Event1” from. Finally = NULL
should be IS NULL
. Here is a correct statement using MYID
field to match records:
UPDATE "Calender2" SET "Event2"= (SELECT
"Calender1"."Event1" FROM "Calender1" WHERE "Calender1"."MYID" = "Calender2"."MYID")
WHERE "Calender2"."Event2" IS NULL
Of course you need to change “MYID” to the field you are matching on.
Thank you very much!
Thanks a lot. Exactly the answer I was looking for.
Other syntax from general MySql code do not work.