romy: COUNT in mehreren Tabellen in MySQL

Beitrag lesen

Hi small-step,

tabelle1

| id | reporter_id | inhalt |
|---------------------------|
| 1  | 12          | test1  |
| 2  | 12          | test2  |
| 3  | 7           | test3  |

tabelle2

| id | reporter_id | active | inhalt |
|------------------------------------|
| 1  | 12          | 1      | test1  |
| 2  | 12          | 0      | test2  |
| 3  | 7           | 0      | test3  |

$ID sei 12

SELECT
   COUNT(*)
   FROM tabelle1 AS t1
   INNER JOIN tabelle2 AS t2
   ON t1.reporter_id = t2.reporter_id
   WHERE t2.active = '1' AND t1.reporter_id = {$ID}

sollte 3 liefern.
idt active ein char-Feld? Ansonsten t2.active=1

Kann leider nicht testen. Gehts ?

ciao
romy