7 ms·
SQL is terrible at allowing this sort of transformation. One benefit of PRQL [disclaimer: maintainer] is that it's simple to add additional logic — just add a
by maximilianroos 2y ago
SQL is terrible at allowing this sort of transformation.
One benefit of PRQL [disclaimer: maintainer] is that it's simple to add additional logic — just add a line filtering the result:
from users
derive [full_name = name || ' ' || surname]
filter id == 42 # conditionally added only if needed
filter username == param # again, only if the param is present
take 50
- withinboredom 2y agoI do sometimes miss RQL with RethinkDb. It was a cool database.
- anonzzzies 2y agoI never looked into prql; does the ordering matter? As if not , that would be great; aka, is this the same: from users take 50 filter id == 42 # conditionally added only if needed filter username == param # again, only if the param is present derive [full_name = name || ' ' || surname] ? As that's more how I tend to think and write code, but in sql, I always jump around in the query as I don't work in the order sql works. I usually use knex or EF or such where ordering doesn't matter; it's a joy however, I prefer writing queries directly as it's easier.
- bvrmn 2y ago`take 50` of all `users` records in random order and after filter the result with username and id? I hope it's the right answer and prql authors are sane.