Warnung: file_put_contents(/home/www/web1/html/php_dev/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/www/web1/html/php_dev/sys/lib.activity.php (Zeile 58)
Doppelte Sätze finden [Archiv] - PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr
ebiz-webhosting
- Ad -
php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
Doppelte Sätze finden


 
jogisarge
26-03-2004, 09:43 
 
Hallo zusammen !

Wie kann ich in einer DB doppelte Datensätze finden .

d.h. Ich möchte prüfen, ob der Inhalt eines bestimmten Feldes mehrmals vorkommt .


gruss jogi

 
Abraxax
26-03-2004, 09:47 
 
SELECT feld, COUNT(feld) anz FROM tabelle WHERE anz > 1 GROUP BY feld

 
mrhappiness
26-03-2004, 09:48 
 
WHERE anz > 1 :D

wenn schon posen, dann doch bitte richtig ;)

 
Abraxax
26-03-2004, 09:49 
 
Original geschrieben von mrhappiness
WHERE anz > 1 :D
wenn schon posen, dann doch bitte richtig ;) hehe, das steht doch bei mir schon drin.... :D

 
mrhappiness
26-03-2004, 09:50 
 
... :D

 
Abraxax
26-03-2004, 09:51 
 
:cool:

 
jogisarge
26-03-2004, 10:53 
 
Vielen Dank

 
ghostgambler
20-08-2005, 00:00 
 
irgendwie...geht das nicht -.-
SELECT `password`, COUNT(`password`) anz
FROM users
WHERE anz > 1
GROUP BY `password`
gibt mir nur nen #1054 - Unknown column 'anz' in 'where clause'

und wenn ich es so mache:
SELECT `password`, COUNT(`password`) anz
FROM users
WHERE COUNT(`password`) > 1
GROUP BY `password`
#1111 - Invalid use of group function

wenn ich das Where jedoch weg lasse, gibt er mir zumindest die Ergebnisse aus

 
Abraxax
20-08-2005, 00:07 
 
mach mal aus WHERE COUNT(`password`) > 1 ein HAVING COUNT(`password`) > 1

 
ghostgambler
20-08-2005, 00:17 
 
Original geschrieben von Abraxax
mach mal aus WHERE COUNT(`password`) > 1 ein HAVING COUNT(`password`) > 1
dann tut's gar nicht mehr
SELECT `password` , COUNT( `password` ) anz
FROM users
HAVING COUNT( `password` ) >1
GROUP BY `password`
#1064 - You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server
version for the right syntax to use near 'GROUP BY `password'
at line 4

 
Abraxax
20-08-2005, 00:23 
 
das HAVING muss wohl NACH GROUP BY rein.

http://dev.mysql.com/doc/mysql/en/select.html

 
ghostgambler
20-08-2005, 01:00 
 
Original geschrieben von Abraxax
das HAVING muss wohl NACH GROUP BY rein.

http://dev.mysql.com/doc/mysql/en/select.html
ah~
jetzt muss ich nur noch in der Manual gucken was es macht :D
thanks

 
heddesheimer
20-08-2005, 08:16 
 
Und hier noch mal richtig:

select feld, count(feld) as anz
from tabelle
group by feld
having anz > 1

das funktioniert garantiert ;)

Gruß Marian

- -

Alle Zeitangaben in WEZ +2. Es ist jetzt 16:44 Uhr.