How to use sub query or CTE inside values method of insert?

I want to the results from CTE or sub query inside the select
const tableOneSubQuery = db.select({name: tableOne.columnOne}).from(tableOne).as('table_one_sub_query');

db.insert(tableTwo).values({columnTwo: tableOneSubQuery.name});
const tableOneSubQuery = db.select({name: tableOne.columnOne}).from(tableOne).as('table_one_sub_query');

db.insert(tableTwo).values({columnTwo: tableOneSubQuery.name});
This seems to be a wrong way to do this (TypeScript complains). What is the right way to go about this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server