How about? After some search in stack overflow, I could not find the solution to the next problem.
I have the following table, in which there is a column where the number of postings that person has to his name in another table will hurt.
This would be the user table.
________________________________ | user_id | first_name | posts | |_________|____________|_______| | 1 | John | xxxxx | <-- Ahi iria la cantidad de posts. |_________|____________|_______| En este caso 4.
This would be the table of posts
_______________________________ | post_id | author_id | title | |_________|___________|_______| | 1 | 1 | test1 | |_________|___________|_______| | 2 | 1 | test2 | |_________|___________|_______| | 3 | 1 | test3 | |_________|___________|_______| | 4 | 1 | test4 | |_________|___________|_______|
Author id is a foreign key to the user table where it refers to the user with id 1 (John).
If you wanted the value of the user john in the column of posts, be the number of rows that author_id have their id, how would you do? Could it be done that is updated automatically? Thanks in advance