Skip navigation links

MySQL Forums :: German :: SELECT AND SUB SELECT


Advanced Search

SELECT AND SUB SELECT
Posted by: Patrick Gommers ()
Date: February 13, 2013 06:37PM

Guten Tag,

ich arbeite schon eine weile mit MySQL - heute bin ich jedoch was ein seltsames Phänomen gestoßen.

Bei der Auswertung meiner bsv_log Tabelle, stellte ich aufeinmal fest das die Seite auf dem localhost ganz schön lange zum Laden brauch.

CREATE TABLE IF NOT EXISTS `bsv_log` (
`logID` int(11) NOT NULL AUTO_INCREMENT,
`logKey` varchar(255) COLLATE latin1_german1_ci DEFAULT NULL,
`sessionID` varchar(255) COLLATE latin1_german1_ci NOT NULL,
`userID` varchar(255) COLLATE latin1_german1_ci NOT NULL DEFAULT '0',
`query` varchar(255) COLLATE latin1_german1_ci DEFAULT NULL,
`agent` varchar(255) COLLATE latin1_german1_ci DEFAULT NULL,
`ipv4` varchar(45) COLLATE latin1_german1_ci DEFAULT NULL,
`ipv6` varchar(45) COLLATE latin1_german1_ci DEFAULT NULL,
`action` text COLLATE latin1_german1_ci,
`created` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`logID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci AUTO_INCREMENT=1720 ;

SELECT
`a`.`userID`,
( SELECT COUNT( `b`.`logID` ) FROM `bsv_log` AS `b` WHERE `b`.`userID` = `a`.`userID` ) AS `alleLogEintraegeVomUser`,
( SELECT COUNT( `c`.`logID` ) FROM `bsv_log` AS `c` ) AS `alleLogEintraege`
FROM
`bsv_log` AS `a`
GROUP BY
`a`.`userID`

Das Problem ist wohl die alleLogEintraegeVomUser Abfrage.

Mit freundlichen Grüßen

Patrick

Options: ReplyQuote


Subject Views Written By Posted
SELECT AND SUB SELECT 1201 Patrick Gommers 02/13/2013 06:37PM
Re: SELECT AND SUB SELECT 589 Thomas Wiedmann 02/14/2013 12:47PM
Re: SELECT AND SUB SELECT 504 Patrick Gommers 02/14/2013 05:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.