1,105,585 Community Members

How do I store the output of a query in another table?

Member Avatar
apanimesh061
Posting Whiz in Training
216 posts since Nov 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a table ...
Ratings (userid, movieid, ratings, time)
where ...
select count(*) from ratings where userid = X; (No of ratings of a particular user)

Here, X ranges from 1-6040!

How should I get the count of each user and then store it in another table 'Users' in the attribute 'countUsers' ?

Please help !

Member Avatar
aquilax
Junior Poster in Training
71 posts since Jul 2010
Reputation Points: 7 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 

If you want to store the result into empty table:

INSERT INTO Users 
SELECT userid, count(*) 
FROM ratings 
GROUP BY userid
Member Avatar
debasisdas
Posting Genius
6,542 posts since Feb 2007
Reputation Points: 580 [?]
Q&As Helped to Solve: 476 [?]
Skill Endorsements: 25 [?]
Featured
 
0
 

Creating view is a better option for that.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article