update query - join tables - aggregate function

I need to do something like this:

UPDATE t1, t2
SET t1.field = AVG(t2.field)
WHERE t1.key = t2.key

of course I get the error:
"Invalid use of group function"

Any Ideas?
arielbfAsked:
Who is Participating?
 
Pratima PharandeCommented:
Update t1

set t1.field = ( select AVG(t2.field) from t2 WHERE t1.key = t2.key )
0
 
arielbfAuthor Commented:
Perfect, Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.