I have two tables as user_shows, and comments. They both have a key in common as id.
I want to have a column in user_shows, which will store the number of comments in the comments table when user_shows.id = comments.id. I tried, and came up with something like:
ALTER TABLE user_shows
ADD num_comments INT(4) AS (SELECT id
FROM comments,
user_shows
WHERE comments.id = user_shows.id)
…but this didn’t work.
you have to write two separate queries like this:-