SQL Question - Implement With Global Tags (?)

Hey guys,
I'd like to gather some Index page contain some dynamic tables of notes with custom fields.
I don't want to use Database feature because I rather the tables will update automatically.

I tried read this article: Some useful SQL snippets
In addition I tried to look in Query Plugin however I didn't understand how to implement it for my needs.

Example:

SELECT * FROM GLOBALTAGS 
WHERE GLOBALTAGS = Tools
Fields Page_name, GLOBALTAG, ANOTHER_GLOBALTAG_NAME
Groupby ANOTHER_GLOBALTAG_NAME

It seems there is only 2 tables (?): blocks/attributes.
Is there more? where can I read more about SQL in SiYuan? If anyone could help with implement example for my query it could be great.

Thanks ahead for all your wonderful work :)

    Welcome to here!

    Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.

    Signup About
    Please input reply content ...
    • zxhd86 1

      You can refer to this, although it is in Chinese, it should be well understood using web translation software: https://docs.siyuan-note.club/zh-Hans/reference/database/table.html

    • zxhd86

      Regarding the query plugin, which specific plugin are you referring to? It seems like there are several query plugins in SiYuan.

      1 Reply
    • Ramos
      VIP Warrior Author

      Hey, I watch the docs you provide and the closest SQL query I succeed to make is: `

      SELECT * FROM blocks WHERE tag LIKE'%Cyber%' LIMIT 2

      I want to implement 2 queries:

      1. show list of only the doc's names with link to them with that belong for a specific tag.

      2. table contains doc's names (lets say for the example that every doc is a tool and those tools are subdocs in doc named "Tools"). with the field of the tool type (it'll be a tag)
        example:

        doc name tool (tag)
        [[Leonardo AI]] AI , IMG
        [[Github Coo-pilot]] AI , Code

        I download this query widget but I don't understand how to use it:

      image.png

    • zxhd86

      This matter involves advanced SQLite queries, which are not as straightforward as they may seem. Here is a feasible example:

      SELECT '[\[' || doc.content || '\]](siyuan://blocks/' || tag.id || ')' AS __1____pre__title, 
      tag.tag AS __2____pre__tag
      FROM blocks AS doc, 
          (SELECT *
          FROM blocks
          WHERE tag LIKE "%Cyber%" ) AS tag
      WHERE doc.id = tag.root_id
      

      If you need to write similar content on your own, you must understand the functions of subqueries and join queries in SQL queries.