Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2005-01-24 : 19:18:41
|
| I have 2 tables. I need to update a field in table 1 from a field in tabletwo. Here is the tricky part...Table two has 3 fields UnitCode, UnitName and StateTable one has 3 fields QuestionID, OptionText and OptionOtherA concatinated state and unitname from table 2 was added to optionsText intable one. They were supposed to add UnitCode to OptionOther at the sametime , but did not. How can I do this now and be accurate. Here is anexample of the tables:Table1:USA-MA-AA-MD-103-1-IL Lexington Market / Store MDUSA-MA-AA-MD-109-1-IL Security Square Mall / Store MDUSA-MA-AA-MD-110-1-IL St. Charles Towne Center / Store MDTable2:33 MD, Lexington Market / Store 033 MD, Security Square Mall / Store 033 MD, St. Charles Towne Center / Store 0 |
|
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2005-01-24 : 20:21:14
|
| This did not work:UPDATE FormCreator_QuestionOptionsSET FormCreator_QuestionOptions.OptionOther = franchisees.UnitCodeFROM franchiseesWHERE (FormCreator_QuestionOptions.optiontext LIKE franchisees.UnitName) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-01-24 : 20:26:46
|
| I am having a hard time understand what you are asking for. You posted the sample data, but you didn't post the expected result set using that sample data. But maybe this is what you are looking for:UPDATE fSET OptionOther = f.UnitCodeFROM franchisees fINNER JOIN FormCreator_QuestionOptions fqON f.SomePKColumn = fq.SomePKColumnWHERE f.optiontext LIKE f.UnitNameTara |
 |
|
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2005-01-24 : 22:15:24
|
| I need to have that data like33 MD, Lexington Market / Store USA-MA-AA-MD-103-1-IL33 MD, Security Square Mall / Store USA-MA-AA-MD-109-1-IL 33 MD, St. Charles Towne Center / Store USA-MA-AA-MD-110-1-IL |
 |
|
|
|
|
|