|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
update from second tablehow do i make this work? do i need a join?
this works in access: UPDATE tblCaseProfiles, tblProviderInvestigatorProfile SET tblCaseProfiles.NewInvestigator = tblProviderInvestigatorProfile.PI_KEY WHERE tblCaseProfiles.Investigator=tblProviderInvestigatorProfile.IP_KEY; hi
probably you can try this UPDATE tblCaseProfiles SET tblCaseProfiles.NewInvestigator = tblProviderInvestigatorProfile.PI_KEY FROM tblCaseProfiles INNER JOIN tblProviderInvestigatorProfile ON tblCaseProfiles.Investigator=tblProviderInvestigatorProfile.IP_KEY -- Show quotebest Regards, Chandra http://chanduas.blogspot.com/ http://groups.msn.com/SQLResource/ --------------------------------------- "mcnewsxp" wrote: > how do i make this work? do i need a join? > this works in access: > > UPDATE tblCaseProfiles, tblProviderInvestigatorProfile SET > tblCaseProfiles.NewInvestigator = tblProviderInvestigatorProfile.PI_KEY > WHERE tblCaseProfiles.Investigator=tblProviderInvestigatorProfile.IP_KEY; > > > ">
> UPDATE tblCaseProfiles gosh you're fast today!> SET > tblCaseProfiles.NewInvestigator = tblProviderInvestigatorProfile.PI_KEY > FROM tblCaseProfiles > INNER JOIN tblProviderInvestigatorProfile > ON tblCaseProfiles.Investigator=tblProviderInvestigatorProfile.IP_KEY > > i got it working much the same as you but with a where clause instead of inner join. 1) Stop using that silly "tbl-" prefixes in violation of ISO-11179
2) An UPDATE clause has one and only one base table name 3) Never use the proprietary UPDATE.. FROM.. syntax; it is unpredictable and hides cardinality violatins 4) A data element has one and only one name. A data element is never named for where or how it is used, so why did you name an investigaror both "investigaror" and "pi_key"? 5) Here is a direct translation to Standard SQL UPDATE CaseProfiles SET new_investigator = (SELECT P.investigator FROM ProviderInvestigatorProfiles AS P WHERE CaseProfiles.investigator = P.investigator); |
|||||||||||||||||||||||