CanMan2004 Posted November 13, 2006 Share Posted November 13, 2006 Hi allI want to perform a select * query within phpmyadmin which would return all records where the field 'name' has more than one record with that stored.For example, my table is called 'people' and the field I want to query is 'name', a snippet of the data is;id name-- ------1 Dave2 Edward3 Sarah4 Bill5 Dave6 Henry7 Bill8 Daveand when I run the query it would return just the recordsid name-- ------4 Bill7 Bill1 Dave5 Dave8 Daveas there is more than one record with the name 'bill' & 'dave'Can this be done?Thanks in advanceDave Link to comment https://forums.phpfreaks.com/topic/27145-returning-duplicate-entries/ Share on other sites More sharing options...
blear Posted November 13, 2006 Share Posted November 13, 2006 trySELECT * FROM people a, people b WHERE a.id != b.id AND a.name=b.name Link to comment https://forums.phpfreaks.com/topic/27145-returning-duplicate-entries/#findComment-124094 Share on other sites More sharing options...
lead2gold Posted November 13, 2006 Share Posted November 13, 2006 This might work too:[code]SELECT t.id,t.name FROM table t WHERE name IN (SELECT t2.name FROM table t2 GROUP BY t2.name HAVING count(*) > 1)[/code] Link to comment https://forums.phpfreaks.com/topic/27145-returning-duplicate-entries/#findComment-124099 Share on other sites More sharing options...
CanMan2004 Posted November 13, 2006 Author Share Posted November 13, 2006 thanks everyone Link to comment https://forums.phpfreaks.com/topic/27145-returning-duplicate-entries/#findComment-124171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.