I need to select all values from all rows by one column in my table. I have
ID TAGS
1 girls, womens, cars
2 girls, world, flowers
3 weapons, cars, boys
so after SQL I should get an array:
array('girls', 'womens', 'cars', 'girls', 'world', 'flowers', 'weapons', 'cars', 'boys')
so how my sql should look like?
Like you see now this will only give you headaches. Normalize your table.
USER_ID TAG
1 girls
1 women
1 cars
2 girls
...
After that you could select your desired result like this
select group_concat(distinct tag)
from your_table
Use GROUP_CONCAT() . A similar answer is already here MySQL DISTINCT on a GROUP_CONCAT() .
I can atleast give a sample solution:
someone can put these example and make a solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.