有思路,但是效率太差,要不断的遍历整个数据库表格,在SQL中有没有简单的方法呢,正在寻找中。。。。。。 select id from answer_newwhere (property1,property2,property3) IN (select property1,property2,property3 from answer_new group by property1,property2,property3 having count(*) > 1) 不完全正确 其中,select property1,property2,property3 from answer_new group by property1,property2,property3 having count(*) > 1 查询出数据库中property1,property2,property3相同的数据a1 b2 c1 但是IN的用法是不对的,会提示出现‘第 2 行: ',' 附近有语法错误’或‘当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。’的错误提示信息,原因是IN时, in 里面的查询语句应该只写一个字段 难道只能一个property一个property的去相等么?有没有简便的方法? 目前想到的方法是这个,可也太复杂了吧: select ID from answer_newwhere property1 IN (select property1 from answer_new group by property1,property2,property3 having count(*) > 1)AND(property3) IN (select property3 from answer_new group by property1,property2,property3 having count(*) > 1)AND(property2) IN (select property2 from answer_new group by property1,property2,property3 having count(*) > 1) 如果在程序中实现用真实数据中,要用几个AND才可以?!! 如果多个IN的可以就万事大吉了,还是先将a1 b2 c1的查询结果保存下来,再一个property一个property的去相等吧。。。。。。

评论