Jump to content


Photo

How to create an excel like filter?


  • Please log in to reply
2 replies to this topic

#1 breadnbutter

breadnbutter
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 30 March 2006 - 07:50 AM

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.

#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 30 March 2006 - 12:54 PM

if this is something your will do manually once in a while, I do something like this:

create table tablename select distinct * from thistable
then I delete thistable and rename tablename to thistable

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 30 March 2006 - 01:28 PM

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

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

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users