Jump to content

How to create an excel like filter?


breadnbutter

Recommended Posts

Hi Guys

I'm pretty new to php but have been getting into it on and off over the past year. I pretty much am comfortable getting a search script going and coming back of the data base. But I am trying to think of a way to get php to find duplicats in certain columns and either display then, or only one of them.

Its basically like the advanced filter tool in excel.

I have a large DB that gets added to by multiple sources. Occasionaly info is entered in twice by different people and I need to create an online facility to then weed these out. Basically I need to look at 2 or three columns and look for entries that are the same.

I've tried planning this out in my head, and I was wondering if there was a "same as" or "Equal to " syntax that may work.
Link to comment
https://forums.phpfreaks.com/topic/6162-how-to-create-an-excel-like-filter/
Share on other sites

You could run something like this:
[code]<?php
$query = "SELECT     field1, COUNT(field1) AS Cnt
FROM         tablename
GROUP BY field1
HAVING      (COUNT(field1) > 1) ";
?>[/code]

That assumes you can use the HAVING clause in your DBMS.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.