我在MySQL列(extraData
)中存储了一些额外的表单数据,格式为JSON。
示例数据:
{"1":{"name":"sadsdaf ","surname":"sdafa","occupation":"sdaas","email":"dsasdaf@asdf.nl","barcode":"052355491"},"2":{"name":"sadafd","surname":"sdafa","occupation":"sddaf","email":"sda@daf.nl","barcode":"052355492"}}
我想进行一个搜索查询,也搜索存储在json编码字段中的条形码?而不仅仅是这样。
$sql = "SELECT name FROM visitors WHERE barcode = '".$barcode."'";
但同时也
$sql = "SELECT name FROM visitors WHERE barcode = '".$barcode."' OR extraData = '".$barcode."'";
我需要如何修改
extraData
变量,才能检查条形码并获得相应的姓名、姓氏等信息?