Jump to content

distinct values from multiple columns?


schilly

Recommended Posts

If I have a table of items with two columns set for categories, say cat1 and cat2 so I can list an item in multiple categories.

 

What's the best way to get a list of all the unique categories? Some categories may only be listed in cat1 and some only in cat2 and some in both.

 

ex.

 

cat1 | cat2

cat | dog

house | apartment

dog | cat

 

What query would I use to return:

 

cat

house

apartment

dog

 

(no particular order)

 

I'm trying to use combinations of DISTINCT but it doesn't seem to work.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/201563-distinct-values-from-multiple-columns/
Share on other sites

Thanks for the reply. It's not user inputted.

 

well say you have a primary and secondary categories. one product will want to be listed in cat A as their primary but another product will want to be listed in cat A as their secondary giving you the same category value in both columns.

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.