从使用codeigniter以逗号分隔的字段值存储的表中获取值

时间:2017-07-14 10:21:59

标签: php database

这是我的communication_posting表

enter image description here

进入字段2,3是user_master表中的user_id。这是我的user_master表(用于登录)。

enter image description here

我想获取session_id意味着存储在communication_posing表的列中,但是这里有两个session_id(意思是user_id)存储了如何只从中获取一个。

1 个答案:

答案 0 :(得分:0)

如果您在两个单独的查询中执行此操作,则可以使用php explode()

$explode_array = explode(',', $database_result['to']);
$value_you_want = $explode_array[0];

如果需要在SQL中执行此操作,请在MySQL中创建拆分函数。这个问题有一些有用的答案。

Can you split/explode a field in a MySQL query?