select advanced sql

0

I would like the column id_post_gru to be populated by 2 based on the number of group id where there is 70

I did this separately works but not together!

UPDATE
  posts
SET
  id_post_gru =(
  SELECT
    COUNT(id_grupo)
  FROM
    posts
  WHERE
    id_grupo = 70
)
    
asked by anonymous 12.03.2018 / 22:08

1 answer

0

Add the clause GROUP BY would look like this:

UPDATE posts 
    SET id_post_gru = (
        SELECT COUNT(id_grupo) 
        FROM posts WHERE id_grupo = 70
        GROUP BY id_group
    );
    
12.03.2018 / 22:19