我正在清理我的代码,我应该将以下函数更改为MySQL查询吗?如果是这样,那么实现这一功能的MySQL功能会是什么?
public ArrayList getNewTitles(ArrayList candidateTitles, ArrayList existingTitles) {
ArrayList newTitles = new ArrayList();
Movie movie = new Movie();
boolean isNew = true;
for(int i=0; i<candidateTitles.size(); i++) {
for(int j=0; j<existingTitles.size(); j++) {
movie = (Movie)existingTitles.get(j);
if(((String)candidateTitles.get(i)).equals(movie.getRawTitle())) {
isNew = false;
}
}
if(isNew == true) {
System.out.println("newTitle for crawling: " + (String)candidateTitles.get(i));
newTitles.add((String)candidateTitles.get(i));
}
else {
System.out.println("candidate binned: " + (String)candidateTitles.get(i));
}
isNew = true;
}
return newTitles;
}
答案 0 :(得分:1)
不知道你的表结构,我猜它可能是这样的:
SELECT * FROM movies WHERE title NOT IN (SELECT title FROM existingTitles);