MYSQL-UPDATE mit IN-und Unterabfrage

Hi ich habe Tabellen wie diese :

Tabelle Eintrag :

id | total_comments

_____________________

1 | 0

2 | 0

3 | 0

4 | 0

Tabelle Kommentare :

id | eid | Kommentar

_____________________

1 | 1 | Kommentar sdfd

2 | 1 | Tests

3 | 1 | comment-text

4 | 2 | dummy-Kommentar

5 | 2 | Probe Kommentar

6 | 1 | fg fgh dfh

Abfrage, die ich schreiben :

UPDATE entry 
   SET total_comments = total_comments + 1 
 WHERE id IN ( SELECT eid 
                 FROM comments 
                WHERE id IN (1,2,3,4,5,6))

Ergebnisse, die ich erhalten :

Tabelle Eintrag :

id | total_comments

_____________________

1 | 1

2 | 1

3 | 0

4 | 0

Erwartete Ergebnisse :

Tabelle Eintrag :

id | total_comments

_____________________

1 | 4

2 | 2

3 | 0

4 | 0

Jede Hilfe wird geschätzt.

InformationsquelleAutor Johal | 2010-06-07
Schreibe einen Kommentar