We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,886 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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 !

3
Contributors
2
Replies
14 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
apanimesh061
Posting Whiz in Training
216 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

If you want to store the result into empty table:

INSERT INTO Users 
SELECT userid, count(*) 
FROM ratings 
GROUP BY userid
aquilax
Junior Poster in Training
73 posts since Jul 2010
Reputation Points: 18
Solved Threads: 11
Skill Endorsements: 0

Creating view is a better option for that.

debasisdas
Posting Genius
6,968 posts since Feb 2007
Reputation Points: 722
Solved Threads: 457
Skill Endorsements: 20

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0777 seconds using 2.66MB