基于多个列删除重复项

时间:2019-05-09 09:30:39

标签: mysql sql

我有一个由(col1,col2,col3)组成的多个字段主键。 但是,在添加PK之前,已经添加了很多重复项,需要将其删除。

对于我的桌子,如果我有:

  public static void mainx(String args[])throws IOException  { 
    Document doc=Jsoup.connect("https://www.ixigo.com/medical-shops-pharmacy-dispensary-in-at-around-near-india-lp-1475537").get();
    Elements ele=doc.select("div.namedentity-item.row");
    for(Element element:ele) {
      System.out.println(element.getElementsByTag("a").attr("href"))
      System.out.println(element.getElementsByClass("ne-title").text());
      System.out.println(element.getElementsByClass("ne-address").text());
    }
  }

查询应导致

Col1 Col2 Col3
---- ---- ----
  2    3   3
  2    3   3
  2    3   4
  2    4  null
  2    4  null

只有第三列可以为空。

1 个答案:

答案 0 :(得分:0)

使用distinct

select distinct col1, col2, col3
from tablename
相关问题