Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL query to return all rows that contain duplicate data from one field

Tags:

sql

sql-server

I have a table with card numbers and names. Some of those names are the same, meaning they have multiple cards. How can I select all the rows where the name occurs more than once?

like image 364
TheDudeAbides Avatar asked Sep 15 '25 04:09

TheDudeAbides


1 Answers

Following may be the solution you are looking for

Select * from CardTable where cardid in ( select cardid from CardTable group by cardid having count(cardid) > 1)
like image 195
Pranay Rana Avatar answered Sep 17 '25 20:09

Pranay Rana