How to construct Subselects with v0.30.0? #379
-
I am struggeling to compose a query with subselects.
What I try to accomplish is to select all events where a searchArg is contained in event.name, event.description or trach.name
with $1 beeing the searchArg I used the code generation and this works fine.
So far so good. A sub select could be this one
My problem is to combine this with the above query. Can someone give me a hint? |
Beta Was this translation helpful? Give feedback.
Answered by
stephenafamo
Mar 21, 2025
Replies: 1 comment 1 reply
-
Try this: searchArg := psql.Arg("%" + "search" + "%")
query := models.Events.Query(
psql.Or(
models.SelectWhere.Events.Name.ILike(searchArg),
models.SelectWhere.Events.Description.ILike(searchArg),
models.EventColumns.TrackID.In(psql.Select(
sm.Columns(models.TrackColumns.ID),
models.SelectWhere.Tracks.Name.ILike(searchArg),
sm.From(models.TrackColumns.Name).As("t"),
)),
),
)
res, err := query.All(context.Background(), exec) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stephenafamo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: