View Full Version : Search based on multiple fields

04-22-2013, 04:30 AM
I'm looking to modify a search query I have that searches on a single field, but returns results from all fields. What I want to do, since duplicates exist under certain conditions, is eliminate the duplicates from displaying on the wildcard search.

Fields are Display, Link, Category, UniqueID

The wildcard is searching on the Link field using %domain% to pull in all data.
I'm using PHP to generate a URL. The duplicates can exist as the same URL can be entered with multiple Category field entries.

Right now my query looks like this:

SELECT * FROM `mytable` WHERE `Link` LIKE '%domain%'");

I'm thinking that I can do something with either the Category or UniqueID fields, but the syntax is not coming to me when I think of how I should be writing it.

04-22-2013, 04:42 AM
I may have answered my own question, but I'll leave it up in case I am way off base.

If I use a GROUP BY and group it by Link, then it will only display each link in the resulting php output 1 time, thus eliminating my duplicates as only the URL shows in the output, not the Category or UniqueID fields.