RENAME TABLE foo TO tmp;
CREATE TABLE foo LIKE tmp SELECT DISTINCT null, title, country FROM tmp;
DROP TABLE tmp;
Just be careful, this will not keep the same IDs, but will be faster than the GROUP solution.
If you want to keep the IDs, I would do this:
RENAME TABLE foo TO tmp;
CREATE TABLE foo LIKE tmp;
ALTER TABLE foo ADD UNIQUE(title,country);
INSERT IGNORE INTO foo SELECT * FROM tmp ORDER BY id ASC;
DROP TABLE tmp;
type in rudys alter table statement, making sure the name name of the table matches that of your db table. et voila The unique constraint will have been added and you won’t get any duplicates any more, where those two columns are concerned.
#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 ‘SHOW CREATE TABLE’ at line 4
[FONT=“Georgia”]I tried approaching the problem from another angle; At data entry rather than at database settings.
I truncated the whole damn table, then tried changing the input code in my PHP form to INSERT IGNORE.
That failed miserably; Instead of importing the thousands of record in my tab-delimited text file, it imported only one, with no data, and with an id (‘categories_id’) of 0.
And actually, I noticed when I scrapped that, removed the IGNORE, and re-imported the data, ALL of the id’s were 0!
It’s actually not a problem, because I’m referencing the records by ‘categories_unique’, but it’s puzzling.
It was being used at first, but the plan changed during building. The ‘categories_id’ column’s only there now because it would be more hassle to remove than keep it in.
[FONT=“Georgia”]I’m still getting that “#1071 - Specified key was too long; max key length is 1000 bytes” error.
I made a file to clean redundant data after input, so I’ll just manually run that after data uploads (or redirect the input form to it).
In my next big database project I’ll spend sometime figuring out the ADD UNIQUE tools before beginning anything. This project isn’t paid well enough to fret over it now.