Select advanced sql

Asked

Viewed 189 times

0

I would like the column id_post_gru to be filled in 2 based on the amount of id_group where there is 70

I did it separately and it works, but together it doesn’t!

UPDATE
  posts
SET
  id_post_gru =(
  SELECT
    COUNT(id_grupo)
  FROM
    posts
  WHERE
    id_grupo = 70
)

1 answer

0

Add the clause GROUP BY would be as follows:

UPDATE posts 
    SET id_post_gru = (
        SELECT COUNT(id_grupo) 
        FROM posts WHERE id_grupo = 70
        GROUP BY id_group
    );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.