我在数据库(mysql)中有一个字符串,如下所示:
{"StateId":73,"CallTime":"\/Date(1336365498912+0500)\/","CallId":"1336365489.14157","Target":"agi://127.0.0.1"}},"Profile":{"$type":"DataWriter.DbProfile, DataWriterObjects","Name":"DataService","Provider":"mssql","ConnectionString":"Data Source=localhost\\mydb; Database=mydb; User Id=sa; Password=admin;"}}
该字符串是一个包含多个字段的 JSON 对象。问题是我有多个要从数据库中删除的重复行。如果CallId和StateId相同但CallTime不同,则将一行视为重复。所以首先我想获取那些具有相同CallId并忽略CallTime差异的行的重复列表(GROUP BY) 。下面的记录与第一个具有不同的CallTime但相同的CallId,因此它被认为是重复的(基本上不需要考虑CallTime重复)
{"StateId":73,"CallTime":"\/Date(1336365498913+0500)\/","CallId":"1336365489.14157","Target":"agi://127.0.0.1"}},"Profile":{"$type":"DataWriter.DbProfile, DataWriterObjects","Name":"DataService","Provider":"mssql","ConnectionString":"Data Source=localhost\\mydb; Database=mydb; User Id=sa; Password=admin;"}}
那么如何进行 GROUP BY 呢?基本上 GROUP BY 中的所有内容都应该匹配忽略CallTime值。
表结构为
mysql> describe Statements;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| SequenceId | bigint(10) | NO | PRI | NULL | auto_increment |
| Profile | varchar(32) | YES | MUL | NULL | |
| CacheItem | text | NO | | NULL | |
+------------+-------------+------+-----+---------+----------------+
之后,我想删除重复项。有人帮我吗?