1

我有一个名为“数据”的mysql表,

+---------+------------------+------+-----+-------------------+----------------+

| Field   | Type             | Null | Key | Default           | Extra          |
+---------+------------------+------+-----+-------------------+----------------+

| id      | int(10) unsigned | NO   | PRI | NULL              | auto_increment |
| data    | text             | YES  |     | NULL              |                |
| created | timestamp        | NO   | MUL | CURRENT_TIMESTAMP |                |
+---------+------------------+------+-----+-------------------+----------------+

“数据”字段的值如下:

606 | {"first_name":"JOHN","last_name":"SLIFKO","address":"123 main AVE","city":"LAKEWOOD","state":"OH","zip":"20190","home_phone":2165216359,"email":"john@gmail.com",} | 2012-12-04 16:37:23 |

因此,它从我拥有的 PHP 脚本中以 JSON 格式保存记录。

事情是这样的:

如何构建此表以通过每个字段进行更快的搜索或咨询,例如进行搜索或查询,例如:

SELECT * FROM Data WHERE first_name = john;

我怎样才能做到这一点???

请帮忙......

4

1 回答 1

1

哎呀。不是一个好的设计。你能做的最好的事情就是使用like关键字

Select * from Data Where data like '%"first_name":"JOHN"%'
于 2012-12-06T00:15:49.683 回答