Hello,
I have two tables, T1 and T2
T1 gets records created off the web via sql through php and that table triggers a copy to T2.
I then need T2 to send its PK back to T1 as an update to a field there to be used as a fk for future queries.
I am looking at setting up a procedure to do this in mysql (the backend) to call the sql within the procedure.
My objectives are twofold:
1) What is best practice for this type of scenario, and
2) code that works - what I have now isn't working (see below):
UPDATE usermanagement
SET usermanagement.tblClients_fldDRCClientID = ( SELECT
MAX(fldDRCClientID) AS MaxOffldDRCClientID
FROM
usermanagement, tblClients)
WHERE usermanagement(id) = MAX(id);
Note: they will both be the most recent records or last updated or max id's in the primary columns
Thanks!
I have two tables, T1 and T2
T1 gets records created off the web via sql through php and that table triggers a copy to T2.
I then need T2 to send its PK back to T1 as an update to a field there to be used as a fk for future queries.
I am looking at setting up a procedure to do this in mysql (the backend) to call the sql within the procedure.
My objectives are twofold:
1) What is best practice for this type of scenario, and
2) code that works - what I have now isn't working (see below):
UPDATE usermanagement
SET usermanagement.tblClients_fldDRCClientID = ( SELECT
MAX(fldDRCClientID) AS MaxOffldDRCClientID
FROM
usermanagement, tblClients)
WHERE usermanagement(id) = MAX(id);
Note: they will both be the most recent records or last updated or max id's in the primary columns
Thanks!
Last edited: