PHP MYSQL重复行过滤

时间:2015-03-07 14:12:33

标签: php mysql

我想在表格中找到重复的记录

  

table_name:结算   有7个cols,但我只对3个cols值感兴趣。

我想找到行,其中3个cols(套件,注释,数量)值相似

例如:

suite comment amount other col
11     44      0.00    88
11     44      0.00    33
17     48      1.00    11
17     48      1.00    35
17     48      1.00    21

1 个答案:

答案 0 :(得分:0)

不是特别有效,但如果你不需要快速做到这一点。

 Select b.* from
 (SELECT 
     Suite, comment, amount
 FROM
     YourTable
 GROUP BY
     Suite, comment, amount
 Having count(1) > 1) a
 Inner join
 YourTable b
 On a.suite = b.suite and a.comment = b.comment and a.amount = b.amount
相关问题