-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Join two tables across two different schemas ( One database) #1589
Comments
any solution for this one? |
The document says Identifier Syntax, ie, table name, column name, has no place for selecting schema, so if you are doing schemaName.tableName, query might be rendered wrong. It suggested use But I found As so far, I have the following temporary sollutins:
This way need use
This has less benifits to use knex.
The final power. |
Adding one more detail to @codinggirl 's answer: Using joinRaw() you can bind the parameters. Which generates query with an identical syntax all over the query.
Note: Positional bindings ? are interpreted as values and ?? are interpreted as identifiers. Output with bindings on PG: Output with bindings on MSSQL: Meanwhile, without binding, it would always generate: |
Hello,
How can we implement table join across two different schemas but the same database.
Technically schemas are just logical separation of tables within the same database so while writing a SQL query all we need to is prefix them with schema name.
For example,
I could probably write below kenx.js. Does that look good ?
But then i saw .
withSchema
option with knex.js What is the advantage of using that option instead of prefixing the table name with schema. How can I use.withSchema
option to join join tables from two different schemas ?The text was updated successfully, but these errors were encountered: