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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.