I have a table with card numbers and names. Some of these names are the same, that is, they have multiple cards. How can I select all rows where the name appears more than once?
The following might be the solution you are looking for
Select * from CardTable where cardid in ( select cardid from CardTable group by cardid having count(cardid) > 1)
Using:
SELECT t.name FROM TABLE t GROUP BY t.name HAVING COUNT(*) > 1
The following should work:
SELECT * FROM cards c1 INNER JOIN cards c2 on c1.name = c2.name WHERE c2.id <> c1.id
select count(*) as n, [name] from table1 group by [name] having n > 1
if you want whole lines here is a solution that will work for sql 7 and up
SELECT t1.* FROM( SELECT t.name FROM YourTable t GROUP BY t.name HAVING COUNT(*) > 1) t2 JOIN YourTable t1 on t2.name = t1.name