Skip to content

How to do subquery within SELECT list without joining table? #269

Answered by houten11
jamesleeht asked this question in Q&A
Discussion options

You must be logged in to vote

AsTable is used only for the sub-queries in the FROM clause.

stmt := SELECT(
	Car.Name,
	SELECT(
		COUNT(STAR),
	).FROM(
		CarLike,
	).WHERE(
		CarLike.CarID = Car.ID,
	).AS("like_count")
).FROM(
	Car,
)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jamesleeht
Comment options

Answer selected by jamesleeht
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants