如何从逗号分隔值字段中获取唯一值? [英] How to get unique values from comma separated values field?

查看:57
本文介绍了如何从逗号分隔值字段中获取唯一值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格中有一列,其中将值存储为逗号分隔的值,

I've a column in my table where i store the values as comma separated values,

现在我需要列出该字段/列中的所有唯一值.

Now i'm in need of listing all the unique values from that field/column..

我该怎么做?

我正在使用php ..

I'm using php..

推荐答案

如果您使用的是php,则不单独使用mysql,然后 最好的选择是检索该字段,然后使用php来获取您的不同值. explode()是一种很好的方法,然后可以使用array_unique删除重复的值.

Noway with mysql alone if you are using php then best bet is to retrieve the field and then use php to get your distinct values. explode() is a good approach, and then you could use array_unique to remove duplicate values.

http://us3.php.net/manual/zh/function.array-unique.php

您可以规范化数据库

这篇关于如何从逗号分隔值字段中获取唯一值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆