Hey there, I have a table, over 20,000 entries. Each entry has a column called 'tags' Each tag field has something like 'blue, flashing, animated' etc etc I want to somehow pull the data out without the spaces, or commas, and if some of the tags are used more than once, not show them twice. So for example: Entry 1: Tags: blue, flashing, animated Entry 2: Tags: red, flashing, animated I want to echo: blue, red, flashing, animated Could anyone guide me? Thanks!
For php you can use array_unique() PHP: or by mysql you could add a 'GROUP by' statement. If you show us the code your working with presently, someone can advise a solution.
Hi, You can use following mysql functions for generating comma seperated data : # CONCAT() returns NULL if any argument is NULL. mysql> SELECT CONCAT('My', 'S', 'QL'); -> 'MySQL' mysql> SELECT CONCAT('My', NULL, 'QL'); -> NULL mysql> SELECT CONCAT(14.3); -> '14.3' For quoted strings, concatenation can be performed by placing the strings next to each other: mysql> SELECT 'My' 'S' 'QL'; -> 'MySQL' # CONCAT_WS(separator,str1,str2,...) CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL. mysql> SELECT CONCAT_WS(',','First name','Second name','Last Name'); -> 'First name,Second name,Last Name' mysql> SELECT CONCAT_WS(',','First name',NULL,'Last Name'); -> 'First name,Last Name'