There cannot be any cid duplicates; that is a unique key on that table.
Ray Paseur
OK, let's take a step back... What is the expected output from this script, ie, what are you trying to do here?
Richard Korts
ASKER
Ray,
It's kind of a long story.
In March, the table customer in the mysql database was created basically by uploading ALL the records in customer.txt; there are some axillary tables, one called comments. For reasons not relevant here, that is a separate table on the MySQL database.
Today the customer informed me of an anomaly. There was a record in the comments table for which there is no customer in the customer table.
So my first idea was just read through the .txt file & do a sql query on the customer table & echo the ones not there.
I guessed it would be a handful; I know there are only 2 between customers #'s 15000 and 17000.
FYI, the customer number start at 10000 and go to 23xxx.
>> Today the customer informed me of an anomaly. There was a record in the comments table for which there is no customer in the customer table.
That implies that these tables are related a common field. Let's say you have
Customers
=========
cid -- this is the primary key
Comments
=========
id -- this is the primary field
cid -- this is the "link" between these two tables.
You can try executing:
SELECT A.cid FROM Comments A WHERE NOT EXISTS( SELECT B.cid FROM Customers B WHERE B.cid=A.cid)
You should get the cid values in Comments that don't have a matching/related record in Customers.
Richard Korts
ASKER
The problem was caused by GoDaddy server taking too long to execute; they (GoDaddy) seemed to have fixed the problem, my originally posted query works fine now.
I suspected this because of other issues going on with other parts of our system.
Thanks, I'll try that.
There cannot be any cid duplicates; that is a unique key on that table.