>Hi,
>How would a word a select statment, to search a database for duplicate
>entries in one field.
>
>For example, the fields: device, hostname, IP, comments
>
>I want to find all instances where there my be two devices with the same
>hostname.
>
>Thanks!
>
>Pete
Sir, try the following.
SELECT DISTINCT device, hostname
FROM <table_name>
GROUP BY hostname
HAVING Count(*) > 1;
Only one of the two or more devices will be listed.
If you want to include cases where the same device has been listed
twice with the same hostname, leave out the DISTINCT.
WOMM (Works On My Machine)
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak
MySQL list magic words: sql query database
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php