0
我在數據庫(MySQL的),它就像一個字符串:刪除重複行GROUP BY與LIKE
{"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的重複列表(GROUP BY)列表,並忽略差異CallTime。下面記錄有不同CallTime從第一個,但同樣呼叫ID,因此它被認爲是重複的(基本上不用考慮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通過?基本上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 | |
+------------+-------------+------+-----+---------+----------------+
之後,我想刪除重複。任何人都幫助我?