[英]MySQL Count multiple values in same column
I have a script storing user generated tags ('keywords') in a database for each added video upload, however it places multiple keywords per item in the same keyword column, space separated. 我有一个脚本,用于为每个添加的视频上传在数据库中存储用户生成的标签(“关键字”),但是该脚本将每个项目的多个关键字放在同一关键字列中,并以空格分隔。 I'm not sure how this can be counted correctly.
我不确定该如何正确计算。 Clearly I'm no expert.
显然我不是专家。
I have a table called ' video ', then within it 我有一个名为“ 视频 ”的表格,然后在其中
Vid keyword
------ -----------
1 cars
2 Cars Audi
3 Boats
4 Trains
5 Aircraft
Is there a way to set it so the spaced value is counted separately? 有没有一种设置方式,以便分开计算间隔值?
If I do 如果我做
SELECT keyword FROM video ORDER BY keyword ASC LIMIT 200
It returns 它返回
1. Aircraft
2. Boats
3. Cars Audi
4. Trains
Is there a way to have it return; 有没有办法让它返回?
1. Aircraft
2. Audi
3. Boats
4. Cars
5. Trains
And individually recognize the multiple spaced keywords in certain columns. 并分别识别某些列中多个隔开的关键字。
Thanks! 谢谢!
使用这种表结构很难做到这一点...您需要使用keyword
和video_id
创建一个新表 。此表将具有一个primary key
一个foreign key as video_id
和一个keyword field
,该keyword field
只能存储一个关键字
I do not think MySQL alone is capable of doing such a thing. 我并不认为仅MySQL就能做到这一点。 You either need to add some script (I dont know if you are using a script or not) or change the structure of the table.
您要么需要添加一些脚本(我不知道您是否正在使用脚本),要么更改表的结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.