# How to create a link to a org-roam search?

**URL:** https://org-roam.discourse.group/t/how-to-create-a-link-to-a-org-roam-search/85
**Category:** How To
**Created:** [May 7, 2020, 4:07pm UTC](https://org-roam.discourse.group/t/how-to-create-a-link-to-a-org-roam-search/85 "2020-05-07T16:07:00Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![alan](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@alan](https://org-roam.discourse.group/u/alan)
#### Post date: [May 7, 2020, 4:37pm UTC](https://org-roam.discourse.group/t/how-to-create-a-link-to-a-org-roam-search/85/2 "2020-05-07T16:37:18Z")

</div>

Right now you would write your own SQL query for the db. Getting the SQL right isn’t the most fun, but once you have it you’re done.

org-mode helpfully has an `elisp:` link-type that will run any elisp command you use as its ‘path’, eg. `elisp:(find-file "Elisp.org")` [See here](https://orgmode.org/manual/External-Links.html)

Running a query is actually pretty easy if you look in a function like `org-roam-db--get-titles` (do `C-h f` in emacs), or just look through the source code in `org-roam-db.el`.

Once you decide on a query you can either link to it or else use a code block in org-mode to write the code and display the results ([see here](https://orgmode.org/manual/Working-with-Source-Code.html), this is why org-mode is awesome). Something like:

```auto
#+BEGIN_SRC elisp
(org-roam-db-query 
  [:select [from] :from links :where (= to $s1)] "path/to/NoteA")

#+END_SRC

```

That will return all of the filenames to notes that link _to_ Note A. To add more filters (Notes K, M, tags) you can add more SQL or elisp until you get what you want. You can also add things that will output them as `file:` links to make them functional and navigable if you want (sidenote: I’d be interested if this would work for literally any language that has a SQLite package, if people wanted to rabidly avoid learning elisp).

There should probably be an easier way to do all of this in the future. I would guess it would mostly involve the graph abilities people are working on 🙂

EDIT: I should add that `org-roam-db--connected-component` also exists, and may suit your needs!

---

_[View the full topic](https://org-roam.discourse.group/t/how-to-create-a-link-to-a-org-roam-search/85)._
