新的开始
凤凰博报 由你开始

SQL思考题

发表于 2007-06-19 09:25:49

I have 2 tables.  Say table1 has 100 rows.

Table1 has a field 'MFG' which is a 2 char code.

I want to replace the 2 char code with a lookup value from table2 which may or may not include all 2 char codes...

So I do:

SELECT TABLE2.MFG_CODE FROM table1 LEFT OUTER JOIN table2 ON table1.MFG=table2.MFG;

Because table2 does not contain all possible MFG codes in table1, the query is returning more than the number of rows originally in table1.

Question:  Is there a simpler way to do a lookup of the value I need from table2 while returning all (but not more) rows from table1?

分享 浏览(303) 评论(0)
上一篇 << 迭代算法求解八皇后问题      下一篇 >> 我的

登录以后再发表评论。

关于博主

justforfun

海明威说-- “这个世界是美好的,值得我们为之奋斗” 我相信后半句...

加为好友

给博主留言    查看留言

文章列表

文章分类

最近发布