Last active
August 26, 2019 06:41
-
-
Save jgreco/09d1d4899178b2db484a667524936ad0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(query-exec (sqldb-param) | |
(prepared (string* "INSERT OR REPLACE INTO TagCardinalities (a,b,cardinality)" | |
" SELECT min($1,t.tag_id),max($1,t.tag_id),ifnull(sub.cnt,0) " | |
" FROM Tags t LEFT JOIN" | |
"(SELECT tag_id, COUNT(*) as cnt FROM FileTags WHERE file_id IN " | |
"(SELECT file_id FROM FileTags WHERE tag_id=$1)" | |
"GROUP BY tag_id) AS sub" | |
"ON t.tag_id = sub.tag_id")) | |
a-id))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment