db: add tagged_media_view

This commit is contained in:
Lucas 2023-03-08 20:43:56 +00:00
parent b1f2e533c1
commit 555a0bc1d1
3 changed files with 95 additions and 8 deletions

View file

@ -1,4 +1,4 @@
-- DROP VIEW tagged_media_view;
DROP VIEW tagged_media_view;
DROP VIEW tag_count_view;
DROP TABLE media_tags;
DROP TABLE tags;

View file

@ -26,10 +26,13 @@ FROM tags
INNER JOIN media_tags USING (tag_id)
GROUP BY tag_id;
-- CREATE VIEW tagged_media_view AS SELECT
-- tags.tag_id AS tag_id,
-- tags.name AS tag_name,
-- media.media_id AS media_id
-- FROM media
-- INNER JOIN media_tags USING (media_id)
-- INNER JOIN tags USING (tag_id);
CREATE VIEW tagged_media_view AS SELECT
media.media_id AS media_id,
media.seaweedfs_fid AS media_seaweedfs_fid,
media.filename AS media_filename,
media.content_type AS media_content_type,
tags.tag_id AS tag_id,
tags.name AS tag_name
FROM media_tags
INNER JOIN media USING (media_id)
INNER JOIN tags USING (tag_id);