shahnawaz Posted December 22, 2008 Share Posted December 22, 2008 Hi, i just want to find out total no. of records in a table which is having same information in some fields of that table mean matching information in the fields. i can elaborate it as suppose i have a survey table which is having 4 answers fields and there are thousands of records in that table, i want to know how many people have given same answers. Please help me to write db query. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/137974-how-to-find-total-no-of-records-in-a-table-having-same-info/ Share on other sites More sharing options...
btherl Posted December 23, 2008 Share Posted December 23, 2008 It sounds like you can use "group by" for this. Eg SELECT a1, a2, a3, a4, count(*) FROM tab GROUP BY a1, a2, a3, a4 HAVING count(*) > 1 That will give you a list of all sets of answers which appeared more than once in the table, and a count of each. Is that what you want? Quote Link to comment https://forums.phpfreaks.com/topic/137974-how-to-find-total-no-of-records-in-a-table-having-same-info/#findComment-721994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.