| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|||
query containing entries that begin with same 3 letters as at least one other entry?How do i create a table from another table containing only those beginning with the same three letters as another entry in the table
so... abc hello abc goodbye ghj must ghjsomthing would all be in the new table |
|
|||
INSERT INTO dups SELECT * FROM scores WHERE substring(player FROM 1 FOR 3) IN (SELECT substring(player FROM 1 FOR 3) FROM scores GROUP BY substring(player FROM 1 FOR 3) HAVING count(*) > 1);Please, do not hesitate to ask for clarifications if so is needed. I would be glad to hear back from you whether the above worked or not. Best Regards, Dimitar |
|
|||
|
Not really an answer, but perhaps a hint: check the manual for whether the is supported by MS SQL. If so it would replace the rightmost select with the group by and having clause, like this
... UNIQUE (SELECT substring(player FROM 1 FOR 3) FROM scores).Hopefully it will be faster. |
![]() |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|