diff --git a/rslib/src/storage/deck/all_decks_of_search_notes.sql b/rslib/src/storage/deck/all_decks_of_search_notes.sql index 0bf183f15..d6012ef3d 100644 --- a/rslib/src/storage/deck/all_decks_of_search_notes.sql +++ b/rslib/src/storage/deck/all_decks_of_search_notes.sql @@ -1,8 +1,9 @@ SELECT nid, did FROM cards -WHERE ord = 0 - AND nid IN ( +WHERE nid IN ( SELECT nid FROM search_nids - ) \ No newline at end of file + ) +GROUP BY nid +HAVING ord = MIN(ord) \ No newline at end of file diff --git a/rslib/src/storage/deck/mod.rs b/rslib/src/storage/deck/mod.rs index d31846fbb..cf408a42d 100644 --- a/rslib/src/storage/deck/mod.rs +++ b/rslib/src/storage/deck/mod.rs @@ -131,7 +131,7 @@ impl SqliteStorage { .collect() } - /// Returns the deck id of the first card of every searched note. + /// Returns the deck id of the first existing card of every searched note. pub(crate) fn all_decks_of_search_notes(&self) -> Result> { self.db .prepare_cached(include_str!("all_decks_of_search_notes.sql"))?