从具有多个值的sql单元格中选择一个值

时间:2018-03-08 12:07:43

标签: php mysql

我有一个sql表,其中包含用于预订诊所客户的事件。表值是从Joomla扩展中收集的。 我的问题是,关于客户端的所有信息都收集在一个表格单元格中,如下例所示。

如何取出值

"I_WANT_CLIENT_FIRST_NAME", "I_WANT_CLIENT_LAST_NAME", "I_WANT_CLIENT_EMAIL", "I_WANT_CLIENT_PHONE" and "I_WANT_CLIENT_GENDER"

所以我可以单独使用它们吗?

我对sql没那么多,所以我以前从未见过这种技术。它叫什么?

以下是我专栏的内容:

[{  "id":"1",
    "fieldname":"First Name",
    "fieldtype":"text",
    "varname":"firstname",
    "size":"60",
    "is_email":null,
    "is_required":"1",
    "is_first_name":"1",
    "is_last_name":"0",
    "values":null,
    "ordering":"0",
    "data":"I_WANT_CLIENT_FIRST_NAME"
},

{   "id":"2",
    "fieldname":"Last Name",
    "fieldtype":"text",
    "varname":"lastname",
    "size":"60",
    "is_email":null,
    "is_required":"1",
    "is_first_name":"0",
    "is_last_name":"1",
    "values":null,"ordering":"0",
    "data":"I_WANT_CLIENT_LAST_NAME"
},

{   "id":"3",
    "fieldname":"Email",
    "fieldtype":"text",
    "varname":"email",
    "size":"60",
    "is_email":"1",
    "is_required":"1",
    "is_first_name":"0",
    "is_last_name":"0",
    "values":null,
    "ordering":"0",
    "data":"I_WANT_CLIENT_EMAIL"},

    {"id":"4","fieldname":"Mobile","fieldtype":"text","varname":"mobile","size":"60","is_email":null,"is_required":"1","is_first_name":"0","is_last_name":"0","values":null,"ordering":"0","data":"I_WANT_CLIENT_PHONE"},{"id":"5","fieldname":"Gender","fieldtype":"radio","varname":"gender","size":"60","is_email":"0","is_required":"1","is_first_name":"0","is_last_name":"0","values":"Male|Female","ordering":"0","data":"I_WANT_CLIENT_GENDER"
}]

1 个答案:

答案 0 :(得分:-1)

使用DISTINCT:

SELECT DISTINCT first_name, last_name,email, phone, gender FROM your_table WHERE email = 'specified_mail';

您可以对WHERE子句使用任何字段,特别是如果它是唯一的。