Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Mehrere Queries zusammenfassen?

Empfohlene Antworten

Veröffentlicht

Hallo,

ich möchte in meiner PHP-Datei nacheinander mehrere Abfragen aus meiner MySQL-Tabelle durchführen aber irgendwie stehe ich auf dem Schlauch.

Wie kann ich denn mit mysql_query sowas umsetzen? Oder kann ich so eine Query mehrfach untereinander setzen?

Es geht darum, daß ich mit DB-Abfragen einzelne Zahlwerte aus einer Tabelle herausholen möchte und diese dann entsprechend nebeneinander in einer einzigen Zeile erscheinen sollen.

Das muß doch irgendwie gehen?!

Danke+Gruß

etops

wieso willst du das im php machen?

mach doch einfach im sql nen union rein!

Aber COUNTs lassen sich nicht mit UNION verbinden...

Jedenfalls nimmt PHPMyAdmin diese Abfrage schon mal nicht: :confused:


SELECT COUNT(*) AS Abc

FROM test

WHERE 

(spalte1 = 93 OR spalte2 = 93 OR spalte = 93) AND ((reihe1 BETWEEN 41 AND 49) 

OR (reihe2 BETWEEN 41 AND 49) OR (reihe3 BETWEEN 41 AND 49) OR (reihe4 

BETWEEN 41 AND 49) OR (reihe5 BETWEEN 41 AND 49) OR (reihe6 BETWEEN 41 AND 

49) OR (reihe7 BETWEEN 41 AND 49) OR (reihe8 BETWEEN 41 AND 49) OR (reihe9 

BETWEEN 41 AND 49) OR (reihe10 BETWEEN 41 AND 49)) 

UNION

SELECT COUNT(*) AS Def

FROM test

WHERE 

(spalte1 = 93 OR spalte2 = 93 OR spalte = 93) AND ((reihe11 BETWEEN 41 AND 49) 

OR (reihe12 BETWEEN 41 AND 49) OR (reihe13 BETWEEN 41 AND 49) OR (reihe14 

BETWEEN 41 AND 49) OR (reihe15 BETWEEN 41 AND 49) OR (reihe16 BETWEEN 41 

AND 49) OR (reihe17 BETWEEN 41 AND 49) OR (reihe18 BETWEEN 41 AND 49) OR 

(reihe19 BETWEEN 41 AND 49) OR (reihe20 BETWEEN 41 AND 49));

Original geschrieben von etops

Jedenfalls nimmt PHPMyAdmin diese Abfrage schon mal nicht:

Kann ja auch nicht gehen. Wenn das die gleiche DB wie im letzten Thread von dir ist, hast du Version 3.23.48.

Aus dem Link von kills:

UNION ist implementiert in MySQL 4.0.0

Das habe ich zwischenzeitlich schon gesehen.

Tja, das ist wohl schlecht...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.