If I have a table like so:
- Apple
- Orange
- Pear
- Pear
- Orange
How do I view how many different words there are? In this example it would be three:
- Apple
- Orange
- Pear
If I have a table like so:
How do I view how many different words there are? In this example it would be three:
SELECT COUNT(DISTINCT column_name) AS some_alias FROM table_name
group by
or distinct
.
select words_column_name, count(words_column_name) as no_of_repetation from table_name group by words_column_name
.
or just select distinct(words_column_name) from table_name
2.To split the word, there is no in build function, but you can do it using substring() & locate(). like:
SUBSTRING_INDEX(SUBSTRING_INDEX(fullword, ',', 1), ',', -1) AS first_fruit,
TRIM( SUBSTR(fullname, LOCATE(',', fullword)) ) AS last_fruit
But this is applicable only for 2 fruit combination, for more you need to write some php script or mysql function