Back to Kysely

Insert subquery

site/docs/examples/insert/0050-insert-subquery.mdx

0.28.171.2 KB
Original Source

Insert subquery

You can create an INSERT INTO SELECT FROM query using the expression method. This API doesn't follow our WYSIWYG principles and might be a bit difficult to remember. The reasons for this design stem from implementation difficulties.

import { Playground } from '../../../src/components/Playground'

import { insertSubquery } from './0050-insert-subquery'

<div style={{ marginBottom: '1em' }}> <Playground code={insertSubquery} /> </div>

:::info[More examples] The API documentation is packed with examples. The API docs are hosted here, but you can access the same documentation by hovering over functions/methods/classes in your IDE. The examples are always just one hover away!

For example, check out these sections: