Sylphritz
Sylphritz
Explore posts from servers
DTDrizzle Team
Created by Sylphritz on 9/29/2023 in #help
SQLite query returns an incorrect row count in extras
Ah, I see. It seems the query is confused because both tables have a column named "id" so I have to hardcode it like so:
sql`(SELECT count(*) from posts WHERE category_id = categories.id)`
sql`(SELECT count(*) from posts WHERE category_id = categories.id)`
Is there a solution that achieve the same result without hardcoding it like this? EDIT: Never mind, I'm dumb. I can just do this:
sql`(SELECT count(*) from ${posts} WHERE ${posts.categoryId} = ${categories}.${categories.id})`
sql`(SELECT count(*) from ${posts} WHERE ${posts.categoryId} = ${categories}.${categories.id})`
3 replies
DTDrizzle Team
Created by Sylphritz on 9/29/2023 in #help
SQLite query returns an incorrect row count in extras
Update: this is really weird, it just keeps returning 2 for all categories regardless of how many posts I have in each of them...
3 replies