Dataview table query for a field with a link

Things I have tried

I specify a key ‘category’ for each book note, and it may contains a link the category note.
Obsidian provides a backlink table below the category note, which is great, e.g.:

metadata

category:: [[02 MOC-PROGRAMMING]]

Using dataview TABLE query:

table category, topic

from #book
WHERE category.value = "[[02 MOC-PROGRAMMING]]"

Well, it returns

What I’m trying to do

According to the Dataview documentation, the link field type is valid for data annotation, how can I use it in a query statement for comparison? The document says:

  1. [[Link]].value would get the value value from page Link .
  2. Key:: [[Link]] , then you should index into it by just writing Key.value ;

Hi.
Your category field use only one value (in the case, only one link)?
If yes:

TABLE category, topic
FROM #book
WHERE category = [[02 MOC-PROGRAMMING]]

Notes:

  • in the query, don’t use “…” for links > quotations are used for strings, not for links
  • about [[Link]].value, in practical means this:
    • taking your example, for category:: [[02 MOC-PROGRAMMING]], let’s say you have a field called field in your note “02 MOC-PROGRAMMING”… [[Link]].value means that you can query the field through the link in category. In the query below, category.field gives you the value in the field inside the note [[02 MOC-PROGRAMMING]].
TABLE category, topic, category.field
FROM #book
WHERE category = [[02 MOC-PROGRAMMING]]

Thank you so much, I tried without double quotes and it works the way I wanted!

Also very much appreciated the extra point, you explained the meaning of value with ‘field’, that’s much easier to understand than the online doc.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.