kayog123
DTDrizzle Team
•Created by kayog123 on 1/4/2024 in #help
Using parent field on subquery for conditioning.
$query = "SELECT p1.id,
(SELECT COUNT(1)
FROM post_table p2
WHERE p2.parent_id = p1.id) as num_children
FROM post_table p1
WHERE p1.parent_id = 0";
I wanted to use the parent field for my condition on subquery. I keep on reading the docs but couldn't find any on how to do it.
5 replies
DTDrizzle Team
•Created by kayog123 on 11/23/2023 in #help
Multiple subquery on where condition in findMany
I wanted to know if how we could do a multiple subquery on the where condition on findMany.
where: (campaign, { eq, and, exists, or }) =>
and(
...whereCondition,
exists(
ctx.db
.select()
.from(influencerPerSlot)
.where(
and(
eq(campaign.id, influencerPerSlot.campaignId),
eq(influencerPerSlot.userId, userId),
),
),
),
notExists(
ctx.db
.select()
.from(bidWinner)
.where(eq(bidWinner.bidderSlotId, bidderSlot.id)),
),
),
I have this on my where condition but it shows an error ".primary: vttablet: rpc error: code = NotFound desc = Unknown column 'dbName_bidderSlot.id'" . Seems like it could not find the bidderSlot table. but if I replace the "campaign" on the where condition with "bidderSlot" the notExist condition worked but it will show an error "Unknown column dbName_campaign.id" which specify the exist condition.
1 replies