u
This commit is contained in:
@@ -178,3 +178,31 @@ export const DELETE = `
|
||||
DELETE FROM category
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
export const LIST_CHILD_CATEGORIES = `
|
||||
SELECT id
|
||||
FROM category
|
||||
WHERE parent_id = @parentId
|
||||
ORDER BY sort ASC, id ASC
|
||||
`;
|
||||
|
||||
export const GET_CATEGORY_ARTICLE_PICS = `
|
||||
SELECT
|
||||
a.id AS articleId,
|
||||
p.id AS picId,
|
||||
p.hash,
|
||||
p.fullbinary AS buffer
|
||||
FROM categoryarticle ca
|
||||
INNER JOIN article a ON a.id = ca.article_id
|
||||
OUTER APPLY (
|
||||
SELECT TOP 1 ap.pic_id
|
||||
FROM articlepic ap
|
||||
WHERE ap.article_id = a.id
|
||||
ORDER BY ap.sort ASC, ap.id ASC
|
||||
) first_pic
|
||||
INNER JOIN pic p ON p.id = first_pic.pic_id
|
||||
WHERE ca.category_id = @categoryId
|
||||
AND a.parentarticle_id IS NULL
|
||||
ORDER BY a.id ASC
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user