![]() |
Datenbank: MySQL • Version: 4 • Zugriff über: php
COUNT von mehreren Tabellen in einem Query
Hi @all,
ich habe gerade ein Problem mit einem SQL-Query. Ich möchte von mehreren Tabellen die Anzahl der Einträge haben. Ich habe jetzt schon diesen Code
SQL-Code:
aber leider bekomme ich für alle 3 Werte 0 heraus, obwohl in s2b_pic 4 Einträge sind. :gruebel:
SELECT count( p.pic_id ) AS pic_count, count( l.link_id ) AS link_count, count( h.hist_id ) AS hist_count
FROM s2b_history h, s2b_pic p, s2b_links l Ich hoffe, ihr könt mir helfen. :) |
Re: COUNT von mehreren Tabellen in einem Query
Das geht so nicht! Guck dir mal an, wie Group Functions arbeiten.
Wenn, dann geht das so:
SQL-Code:
select 's2b_history' as Tabelle, count(*) as Anzahl from s2b_history
union select 's2b_pic' as Tabelle, count(*) as Anzahl from s2b_pic union select 's2b_links' as Tabelle, count(*) as Anzahl from s2b_links |
Re: COUNT von mehreren Tabellen in einem Query
Danke, das funktioniert perfekt. :thumb:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:22 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz