Ah, now I get you. Let's assume all the data is in one table in the DB and that you have four columns labelled 'Course', 'Horse', 'Trainer' and 'Jockey'. The first thing I'd do is create two additional columns for each of the CHTJ columns as follows:
USE DBname;
ALTER TABLE TableName ADD CrsID INT
ALTER TABLE TableName ADD lcCrs VARCHAR(32)
ALTER TABLE TableName ADD HrsID INT
ALTER TABLE TableName ADD lcHrs VARCHAR(25)
ALTER TABLE TableName ADD TrnID INT
ALTER TABLE TableName ADD lcTrn VARCHAR(40)
ALTER TABLE TableName ADD JckID INT
ALTER TABLE TableName ADD lcJck VARCHAR(40)
I'd then write a routine to reduce the names to their basic form, i.e. no spaces, apostrophes or hyphens, and write them to their respective columns. So, something like:
USE DBname;
UPDATE TableName
SET
lcCrs = LOWER(REPLACE(REPLACE(REPLACE(Course,' ',''),'''',''),'-',''))
, lcHrs = LOWER(REPLACE(REPLACE(REPLACE(Horse,' ',''),'''',''),'-',''))
, lcTrn = LOWER(REPLACE(REPLACE(REPLACE(Trainer,' ',''),'''',''),'-',''))
, lcJck = LOWER(REPLACE(REPLACE(REPLACE(Jockey,' ',''),'''',''),'-','')) (note double '' for apostrophes and commas before the last three rows)
Next, for each of the CHTJ columns, I'd write something like:
USE DBname;
SELECT DISTINCT(lcTrn), Trainer, COUNT(lcTrn) AS 'N0.'
FROM TableName
GROUP BY lcTrn, Trainer
ORDER BY [No.] DESC, lcTrn (note the square brackets due to the point after 'No'
All names with variations in the spelling will have a value > 1, so you can beat them into shape. Once cleaned up, you can then transfer the CHTJ data into their own tables, add their IDs and then add the IDs back into the main table. You'll probably also need Race IDs and store the basic race data in its own table. You'll then need to create Primary keys and their associated Foreign keys, but we can look at that another time.
You'll need to experiment, Kevin, because I don't have a similar situation, so I'm trying to visualise it all in my head. I'm also unsure about syntax differences between MySQL and T-SQL.
Ray