解决 order by 问题
This commit is contained in:
parent
dc80d8d527
commit
7ec08d1e55
@ -27,12 +27,10 @@ SELECT * FROM album WHERE (full_description = '' or full_description is null) an
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
async function fetchAll({ args = {}, isUpdate = false }) {
|
async function fetchAll({ args = {}, isUpdate = false }) {
|
||||||
if (args.order) console.log("存在 DISTINCT,自动升序排序,无需指定ORDER BY");
|
|
||||||
console.log("start fetching albums ...");
|
console.log("start fetching albums ...");
|
||||||
|
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
var sql = `
|
var sql = `
|
||||||
-- SELECT DISTINCT album_id FROM album WHERE (full_description = '' or full_description is null) and description like '%专辑《%》,简介:%' and description not regexp '^.*?专辑《.*?》,简介:[:space:]*?。,更多.*$'
|
|
||||||
SELECT album_id FROM album WHERE (full_description = '' or full_description is null) and description like '%专辑《%》,简介:%' and description not regexp '^.*?专辑《.*?》,简介:[:space:]*?。,更多.*$'
|
SELECT album_id FROM album WHERE (full_description = '' or full_description is null) and description like '%专辑《%》,简介:%' and description not regexp '^.*?专辑《.*?》,简介:[:space:]*?。,更多.*$'
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
@ -42,8 +40,8 @@ async function fetchAll({ args = {}, isUpdate = false }) {
|
|||||||
].join(' AND ');
|
].join(' AND ');
|
||||||
var sql = `
|
var sql = `
|
||||||
-- 查出来通过代码去重,提高速度
|
-- 查出来通过代码去重,提高速度
|
||||||
-- SELECT DISTINCT album_id FROM song_album_relation WHERE ${whereClause} AND album_id NOT IN ( SELECT album_id FROM album )
|
|
||||||
SELECT album_id FROM song_album_relation WHERE ${whereClause} AND album_id NOT IN ( SELECT album_id FROM album )
|
SELECT album_id FROM song_album_relation WHERE ${whereClause} AND album_id NOT IN ( SELECT album_id FROM album )
|
||||||
|
${args.order ? `ORDER BY album_id ${args.order}` : ''}
|
||||||
${args.limit ? `LIMIT ${args.limit}` : ''}
|
${args.limit ? `LIMIT ${args.limit}` : ''}
|
||||||
`;
|
`;
|
||||||
console.log(sql);
|
console.log(sql);
|
||||||
|
@ -23,7 +23,6 @@ async function getFromDatabase({ artistId }) {
|
|||||||
|
|
||||||
// 从数据库中查出还缺少的歌手,并进行爬取
|
// 从数据库中查出还缺少的歌手,并进行爬取
|
||||||
async function fetchAll({ args = {} }) {
|
async function fetchAll({ args = {} }) {
|
||||||
if (args.order) console.log("存在 DISTINCT,自动升序排序,无需指定ORDER BY");
|
|
||||||
console.log("start fetching artists ...");
|
console.log("start fetching artists ...");
|
||||||
let whereClause = [
|
let whereClause = [
|
||||||
args.min ? `artist_id > ${args.min}` : '1=1',
|
args.min ? `artist_id > ${args.min}` : '1=1',
|
||||||
@ -33,6 +32,7 @@ async function fetchAll({ args = {} }) {
|
|||||||
-- 查出来通过代码去重,提高速度
|
-- 查出来通过代码去重,提高速度
|
||||||
-- SELECT DISTINCT artist_id FROM song_artist_relation WHERE ${whereClause} AND artist_id NOT IN ( SELECT artist_id FROM artist )
|
-- SELECT DISTINCT artist_id FROM song_artist_relation WHERE ${whereClause} AND artist_id NOT IN ( SELECT artist_id FROM artist )
|
||||||
SELECT artist_id FROM song_artist_relation WHERE ${whereClause} AND artist_id NOT IN ( SELECT artist_id FROM artist )
|
SELECT artist_id FROM song_artist_relation WHERE ${whereClause} AND artist_id NOT IN ( SELECT artist_id FROM artist )
|
||||||
|
${args.order ? `ORDER BY artist_id ${args.order}` : ''}
|
||||||
${args.limit ? `LIMIT ${args.limit}` : ''}
|
${args.limit ? `LIMIT ${args.limit}` : ''}
|
||||||
`;
|
`;
|
||||||
console.log(sql);
|
console.log(sql);
|
||||||
|
@ -15,6 +15,7 @@ async function fetchAll({ args = {} }) {
|
|||||||
].join(' AND ');
|
].join(' AND ');
|
||||||
var sql = `
|
var sql = `
|
||||||
SELECT 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.order ? `ORDER BY song_id ${args.order}` : ''}
|
||||||
${args.limit ? `LIMIT ${args.limit}` : ''}
|
${args.limit ? `LIMIT ${args.limit}` : ''}
|
||||||
`;
|
`;
|
||||||
console.log(sql);
|
console.log(sql);
|
||||||
|
Loading…
Reference in New Issue
Block a user