开发者

SQL Question: How to avoid 200 If-Else Statements?

I've following tables with the attributes

Table1: [username]    [old_profile]
Table2: [old_profile] [new_profile]
Table3: [username]    [new_profile]    [some_more_attributes]开发者_如何学Python

Table2 declares the rules for renaming "old_profile" into "new_profile" (e.g. if the old_profile was called "Banana300", the new_profile should be called "Chocolate125").

Does anyone know if it's possible to execute that with a SQL/MS Access Query?

If not, I would have to write an external script for this task.

Thanks a lot.

Cheers

EDIT: I forgot to explicitly mention that I want to create Table3 from Table1 and Table2 (ignore the "some_more_attributes").


If I understood your question:

INSERT INTO table3 (username, newprofile) 
SELECT t1.username, t2.newprofile
FROM table1 t1 INNER JOIN table2 t2 ON t1.oldProfile = t2.OldProfile
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜