1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

去除多余DISTICT

This commit is contained in:
2022-10-20 01:01:27 +08:00
parent 5c2ea41a14
commit dc80d8d527
2 changed files with 5 additions and 3 deletions

View File

@@ -8,14 +8,13 @@ const dbUtils = global.dbUtils;
// 从数据库中查出还缺少的歌词,并进行爬取
async function fetchAll({ args = {} }) {
if (args.order) console.log("存在 DISTINCT自动升序排序无需指定ORDER BY");
console.log("start fetching lyrics ...");
let whereClause = [
args.min ? `song_id > ${args.min}` : '1=1',
args.max ? `song_id <= ${args.max}` : '1=1',
].join(' AND ');
var sql = `
SELECT DISTINCT song_id FROM song WHERE ${whereClause} AND song_id NOT IN ( SELECT song_id FROM lyric )
SELECT song_id FROM song WHERE ${whereClause} AND song_id NOT IN ( SELECT song_id FROM lyric )
${args.limit ? `LIMIT ${args.limit}` : ''}
`;
console.log(sql);