I have a table with 4 entries.
CREATE TABLE tab(
name Text
);
INSERT INTO "tab" VALUES('Intertek');
INSERT INTO "tab" VALUES('Pntertek');
INSERT INTO "tab" VALUES('Ontertek');
INSERT INTO "tab" VALUES('ZTPay');
Pntertek & Ontertek are fuzzy duplicates of the correctly spelt Intertek. I wish to create a list consisting of fuzzy duplicates and the correctly spelt names. However, I don't want the list to contain the correctly spelt name if there is no fuzzy duplicate found by the LIKE search.
The following line tells me how many entries match my fuzzy search criteria:
SELECT COUNT(name)
FROM tab
WHERE name LIKE '%ntertek' ;
SELECT COUNT(name)
FROM tab
WHERE name LIKE '%TPay' ;
This works fine and gives 3 and 1 respectively.
I know this next part is wrong but it expresses what I want to happen:
SELECT name
FROM tab
WHERE name LIKE '%ntertek'
GROUP BY name
HAVING COUNT(name) FROM tab WHERE name LIKE '%ntertek' > 1 ;
SELECT name
FROM tab
WHERE name LIKE '%TPay'
GROUP BY name
HAVING COUNT(name) FROM tab WHERE name LIKE '%TPay' > 1 ;
In my mind this should create the following list: Intertek, Ontertek, Entertek.
But I get a near "FROM": syntax error.
I'm somewhat of a novice with sql and programming in general so any help would be greatly appreciated.
Thanks in advance for any help.