I have two tables: news and comments.
i want to count the number of comments for each newsid and update the
count in news.comment
comments.newsid belongs to news.id
can i do this with sub queries? im using v4.1.x
i have many records in the comments table so im not sure what the most
efficient way to do it.
i will likely run this as update every few minutes because doing a join
on the fly is going to hurt performance when i need to display the
comment count on the webpage i think.
any help?
table: news
+----+-----------+
| id | comments |
+----+-----------+
| 26 | 0 |
| 21 | 0 |
| 29 | 0 |
+---------------
table: comments
+-----+--------+
| id | newsid |
+-----+--------+
| 1 | 26 |
| 2 | 21 |
| 3 | 29 |
| 4 | 29 |
| 5 | 29 |
+-------------+
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.2/65 - Release Date: 8/7/2005
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]