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

Multiple value where clause using squirrel #371

Open
AshishMittal02 opened this issue Dec 8, 2023 · 2 comments
Open

Multiple value where clause using squirrel #371

AshishMittal02 opened this issue Dec 8, 2023 · 2 comments

Comments

@AshishMittal02
Copy link

I'm trying to recreate this query with squirrel:

SELECT c.userID, c.name, o.orderID FROM users as c join order as o
    ON c.userID = o.userID where orderID IN ('a', 'b');

The closest I can come up with is this and it's wrong:

query := sq.Select("c.id, c.name, o.orderID").
	From("users").join("order as o using (userID)")
	Where(sq.Eq{
		"id": []string{'a', 'b'},
	})
@AshishMittal02
Copy link
Author

One option is there to have multiple Where(sq.Eq{} but if i have 100 orderIDs it will grow alot and i think it will be ugly

@ysomad
Copy link

ysomad commented Dec 16, 2023

you can use squirrel.And

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

No branches or pull requests

2 participants