Extend GET_CATEGORY_ID_BY_HASH to resolve categorypic hashes directly
This commit is contained in:
@@ -9,11 +9,21 @@ VALUES (
|
||||
`;
|
||||
|
||||
export const GET_CATEGORY_ID_BY_HASH = `
|
||||
SELECT TOP 1 ca.category_id AS categoryId
|
||||
FROM pic p
|
||||
INNER JOIN articlepic ap ON ap.pic_id = p.id
|
||||
INNER JOIN categoryarticle ca ON ca.article_id = ap.article_id
|
||||
WHERE p.hash = @hash
|
||||
SELECT TOP 1 categoryId
|
||||
FROM (
|
||||
SELECT ca.category_id AS categoryId
|
||||
FROM pic p
|
||||
INNER JOIN articlepic ap ON ap.pic_id = p.id
|
||||
INNER JOIN categoryarticle ca ON ca.article_id = ap.article_id
|
||||
WHERE p.hash = @hash
|
||||
|
||||
UNION
|
||||
|
||||
SELECT cp.category_id AS categoryId
|
||||
FROM pic p
|
||||
INNER JOIN categorypic cp ON cp.pic_id = p.id
|
||||
WHERE p.hash = @hash
|
||||
) AS combined
|
||||
`;
|
||||
|
||||
export const GET_FULL_BY_HASH = `
|
||||
|
||||
Reference in New Issue
Block a user