Am I being dim but how do you simulate a `DISTINCT...
# box-products
r
Am I being dim but how do you simulate a
DISTINCT
with Quick/qb
query.select( "username" ).distinct().from( "users" );
a
good find - I couldn't see it in the docs so went to the source code! 🙂
🤘 1
r
Thanks both, I couldn't distinct in the docs??? 🤔 Nothing when I searched??
a
I didn't find it either when I searched the docs
r
¯\_(ツ)_/¯
g
Me neither, but I knew it was related to selecting data, so I just went to that section
👍 1
a
interestingly the 'lens' option in the search returns something
👍 1
r
distinct
applies to the entire query, not just certain fields.
Humm, not sure this is going to be much help 😞
a
That's how distinct works though. What's the plain SQL you want to produce?
r
This is the objective...
Copy code
SELECT DISTINCT brand,country,region,area,shopcode,id
FROM shops
ORDER BY brand,country,region,area
a
so that should be:
Copy code
qb.select( 
["brand","country","region","area","shopcode","id"
]
).distinct()
.from("shops")
.orderBy(["brand","country
","region","area");
i think...
(excuse formatting!)
r
Thanks, I'll give that a go. Just doing a quick test with
raw()
first.
Yep, that's looking good, thanks John 🎉
👍 1