Author |
Topic |
sadbjp
INNER JOIN
41 Posts |
Posted - 2007-05-11 : 13:34:32
|
Hi, I have two tables:1. RubricReportDetail with columns LocalPerf, Age2. SppIndicator with columns Pct, AgeHow can I populate the values of LocalPerf with Pct by matchingRubricReportDetail.Age = SppIndicator.Age ??Please help me. Thanks in advance. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-11 : 13:40:40
|
UPDATE rSET LocalPerf = s.PctFROM RubricReportDetail rINNER JOIN SppIndicator sON r.Age = s.AgeTara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
sadbjp
INNER JOIN
41 Posts |
Posted - 2007-05-11 : 13:42:20
|
Hi,Thanks for the response. What if I don't wanto join INNER join. Is there any other way (simplest one ) to do this?Let me know. Thanks very much. |
|
|
X002548
Not Just a Number
15586 Posts |
|
sadbjp
INNER JOIN
41 Posts |
Posted - 2007-05-11 : 13:45:46
|
It is certainly not a homework assignment but I hate using INNER joins, I want to use another method (just want to avoid joins). Can I use WHERE clause in this? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-11 : 13:48:29
|
you hate using inner joins???maybe you should change the field you work in?joins are a basis of set operations and thus Databases.EDIT: fixed some typos_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-11 : 13:48:31
|
I will not provide bad answers. Learn to write good code and start using joins.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
sadbjp
INNER JOIN
41 Posts |
Posted - 2007-05-11 : 14:05:14
|
Thanks for the help but didn't asked for your opinions about my likes and dislikes. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-05-11 : 14:08:50
|
sadbjp -- it is not an opinion to state that if you don't "like joins", you shouldn't be working with a relational database. that's a fact.- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-11 : 14:08:59
|
It's not about likes and dislikes; it's about writing good, efficient code. The most efficient way to do this is with a join.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
sadbjp
INNER JOIN
41 Posts |
Posted - 2007-05-11 : 14:13:33
|
Alright guys..lets end this here. Thanks once again for your help and guidance. |
|
|
X002548
Not Just a Number
15586 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-14 : 08:45:57
|
[code]UPDATE dSET d.LocalPerf = (SELECT i.PCT FROM SppIndicator AS i WHERE i.Age = d.Age)FROM RubricReportDetail AS d[/code]Peter LarssonHelsingborg, Sweden |
|
|
Vijaykumar_Patil
Posting Yak Master
121 Posts |
Posted - 2007-05-14 : 09:35:13
|
Isn't this slower than Tara's method. Which I normally use. Necessity is the mother of all inventions! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-14 : 10:23:25
|
It can be. It depends on how smart SQL Server is.But it meets OP original condition, NO JOIN ALLOWED.Peter LarssonHelsingborg, Sweden |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-14 : 10:55:59
|
quote: Originally posted by sadbjp It is certainly not a homework assignment but I hate using INNER joins, I want to use another method (just want to avoid joins). Can I use WHERE clause in this?
Which of the following is correct?1 You dont know how to use Join2 You are new to sql and want to use front end's row by row operation (as suggested cursor)3 You dont know how to justify the statement "I hate using INNER joins" MadhivananFailing to plan is Planning to fail |
|
|
|