Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MYSQL UPDATE mit IN und Subquery

Verwendung:

UPDATE entry 
   SET total_comments = (SELECT COUNT(*)
                           FROM COMMENTS c
                          WHERE c.eid = id
                       GROUP BY c.eid)
 WHERE id IN ( SELECT eid 
                 FROM comments 
                WHERE id IN (1,2,3,4,5,6))