Hi all,
I'm using a query to echo all names of categories within a table (column is called category, and every entry/row has a value within the category column)
As I do not want to have duplicate categories echoed, I have selected a distinct query:
$query="SELECT DISTINCT category FROM mytable WHERE area = 'london'
That works fine and only echoes each category once, irrespective of whether or not a category may be mentioned loads of times.
However, I do have some other columns, called category2, category3 and so on. What I would like to do, if possible, is be able to echo the distinct categories from all those columns without duplicates. However, when I use:
$query="SELECT DISTINCT category AND category2 AND category3 FROM mytable WHERE area = 'london'
...I obviously end up with duplicates (i.e, if Linux is listed under all 3 columns, I get Linux echoed 3 times)
Is there a way to echo all entries from all 3 columns, IF they are distinct?
i.e if I have:
category:
linux
unix
windows
linux
windows
unix
category2:
linux
unix
windows
linux
windows
unix
redhat
category3:
linux
unix
windows
linux
windows
unix
quake
...the result shown is:
linux
quake
redhat
unix
windows
(with no duplication)
Any ideas?
TIA,
Jonathen