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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2002-05-16 : 13:44:28
|
| I'm trying to modify my existing database design here. What I need to do is move all the data from FORUM_MEMBERS.M_LEVEL into TBLUSERDETAILS.FORUM_LEVEL. tbluserdetails has a field NAMEONLINE that corresponds with FORUM_MEMBERS M_NAME. How Can I do this? I'm not sure where to go with what I have below so far.insert into tblUserDetails(Forum_Level) select M_Level FROM FORUM_MEMBERS Thanks a bunch |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2002-05-16 : 13:54:21
|
| Can you show us your table structures with all the columns you want moved?My best guess is:INSERT INTO tblUserDetail (Forum_Level, NAMENSONLINE)SELECT M_Level, M_NAMEFROM FORUM_MEMBERSJeremy |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-05-16 : 16:21:06
|
..just a guess....do you want to insert where not exists and update where exists?insert tbluserdetails(forum_level)select m_levelfrom forum_members fwhere not exists ( select 1 from tbluserdetails where nameonline = f.m_name)update tbluserdetailsset forum_level = f.m_levelfrom tbluserdetails u inner join forum_members f on u.nameonline = f.m_name <O> |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2002-05-16 : 17:35:46
|
| Thanks,The two tables are both the same structure. As suchTBLUSERDETAILS ////////// FORUM_MEMBERSNAMEONLINE ////////// M_NAMEFORUM_LEVEL ////////// M_LEVELAll the users names in forum members(M_NAME) exist in tbluserdetails(NAMEONLINE) (they should anyways so unless there are integrity errors, altho I checked and there doesnt seem to be any). I want to get all the corresponding LEVELS over from one table to the other.Thanks, I hope that clears it upEdited by - mike123 on 05/16/2002 17:36:38 |
 |
|
|
|
|
|