Skip to content
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

How to make scalar subquery (query in select)? #139

Closed
usefksa opened this issue Jun 8, 2022 · 2 comments
Closed

How to make scalar subquery (query in select)? #139

usefksa opened this issue Jun 8, 2022 · 2 comments
Labels

Comments

@usefksa
Copy link

usefksa commented Jun 8, 2022

Thanks for the great library.
Is it possible to build a scalar subquery ( query in select ) without using join?
I want to build these MySQL queries:

  • simple
SELECT  posts.id, ( select  tagName FROM  tags  WHERE postTags.postId = posts.id ) AS postTags 
FROM posts WHERE id=1
  • complex
SELECT  posts.id, ( select  GROUP_CONCAT(tagName SEPARATOR "^") FROM  tags  WHERE postTags.postId = posts.id ) AS postTags 
FROM posts WHERE id=1
@shadowhand
Copy link
Owner

These queries would be better served by JOINs, which are available in the query builder. The group_concat can be done with func helper.

@shadowhand
Copy link
Owner

And, if you really wanted to, you could use express(...) to build these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants