I’ve got the following table, and I’m trying experiment with it. Here is the table:
Mobiles:
– id: ‘1’, productname: ‘Apple’
– id: ‘2’, productname: ‘Apple’
– id: ‘3’, productname: ‘Samsung’
– id: ‘4’, productname: ‘Alcatel phone’
– id: ‘5’, productname: ‘Alcatel’
– id: ‘6’, productname: ‘Blackberry’
I’m am currently using this MySQL query to not display the duplicates:
SELECT DISTINCT productname FROM
mobiles
And the result displays:
- Apple
- Samsung
- Alcatel Phone
- Alcatel
- Blackberry
Now my question is if their is anything I can add to my mysql to search the database to check the the first word is not a duplicate or something along those lines? Or if more than 8 characters are the same regard it as a duplicate? So that I can get my data to display as follows:
- Apple
- Samsung
- Alcatel
- Blackberry
I hope Someone out there would be able to help me out with this question.
MySQL’s SUBSTRING_INDEX to the rescue: