How do write a subquery?
See original GitHub issueHi. @tgriesser . first of all congratulations on the superb job you all have been doing creating this tool. It looks amazing and it’s working quite well.
for example (for postgres)
SELECT
*
FROM
tbl_a LEFT join (
SELECT
id, name
FROM
tbl_b
GROUP BY
id, name
) AS tbl_b on tbl_a.id = tbl_b.id
now
Knex('tbl_a').select('*').join(
Knex.Raw('(SELECT id, name FROM tbl_b GROUP BY id, name) AS tbl_b')
,'tbl_a.id', '=', 'tbl_b.id', 'LEFT');
I want to create without the Raw method.
Is it possible to other, using the USING?
thank you.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Writing Subqueries in SQL | Advanced SQL - Mode Analytics
Subqueries (also known as inner queries or nested queries) are a tool for performing operations in multiple steps. For example, if you wanted...
Read more >SQL Subqueries - w3resource
A subquery is a SQL query nested inside a larger query. A subquery may occur in : ... You can use a subquery...
Read more >SQL - Sub Queries - Tutorialspoint
SQL - Sub Queries ; SELECT * FROM CUSTOMERS WHERE ID IN (SELECT ID FROM CUSTOMERS WHERE SALARY > ; UPDATE CUSTOMERS SET...
Read more >5 SQL Subquery Examples | LearnSQL.com
A subquery, or nested query, is a query placed within another SQL query. When requesting information from a database, you may find it...
Read more >SQL Subquery (With Examples) - Programiz
SQL Subquery ; * FROM Customers WHERE age = ( ; customer_id, first_name FROM Customers WHERE customer_id ; DISTINCT Customers.customer_id, Customers.first_name ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is possible:
Hi @dai-yamashita - glad you’re liking it!
Currently there isn’t support for doing sub-queries for joins, and the
Knex.Raw
would be the best way to go about it - though there’s no reason that couldn’t be allowed - I’ll look into adding a way to do it using an independent query:Would this be what you’re looking for?