I am trying to search 1 table in the database and count the number of unique records where 3 fields do not match. I have the below but it doesn't work at all. I am an SQL noob so any help really is appreciated!
This is what I have so far
<? php
SELECT COUNT(*) 
FROM (
SELECT  DISTINCT field1, field2, field3
FROM table1);
$result = $query;
$row = mysql_fetch_array($result);
echo $row;
?>
Thanks for any help!
EDIT: I dont think this syntax does what I need it to.
I need to count the unique records in "table 1" on the basis that the fields "title","firstname", "surname" do not match another rows contents. For example the table below
+---------+-----------+-----------+-----------+
|   ID    |   Title   | Firstname | Surname   |
+---------+-----------+-----------+-----------+
|    1    |    Mr     |    J      |   Doe     |
|    2    |    Mrs    |    J      |   Doe     |
|    3    |    Mr     |    A      |   James   |
|    4    |    Mr     |    J      |   Doe     |
+---------+-----------+-----------+-----------+
The query would need to return the answer 3. There is only 1 row in the table above where "title", "firstname" & "surname" match and therefore does not get counted.
I hope that is a little clearer. I think I must be confused about what DISTINCT does!
EDIT AGAIN:
The "real world" scenario is I have a table with peoples details and want to extract them to send mail out but I do not want duplicates.
 
     
     
     
     
    