Easier way to To do AND + OR in SQL

I love the query builder in Wappler.

The only time I don't love it is when I have

  • multiple "AND" statements
  • with an embedded "OR" statement
  • and each "OR" needs its own condition

Under that specific circumstance, it's hard to click through to get it to fall into place just right in the visual builder.

It'd be nice if there was an easier way to do that.

With the advent of GPTs, I find it much faster and easier to use Database Custom Queries. ChatGPT and Claude are great at creating complex queries with near 0% errors.

Give them access to your codebase, and they do fairly well creating/editing the full API file, as long as you provide examples from previously created APIs.

1 Like

Claude even suggested using views to avoid nested logic, similar to

CREATE VIEW expenses_with_category_match AS
SELECT *
FROM "Finance-Expenses"
WHERE "BudgetCat_ID" = {{$_GET.filter_budget_category}}
   OR "SecondaryBudgCat_ID" = {{$_GET.filter_budget_category}};

The query would then be:

SELECT *
FROM expenses_with_category_match
WHERE "Expense_Description" ILIKE '%' || {{$_GET.filter_description}} || '%'
  AND "DateOfPurchase" BETWEEN {{$_GET.filter_date_purchased_start}} AND {{$_GET.filter_date_purchased_end}};

I have mixed feelings on this.

Yes, AI is a great tool BUT i think it important to review it's suggestions and more importantly UNDERSTAND what it recommends.

Blindly allowing AI to generate code is, in my opinion, a potentially path to disaster in the future if you dont 100% understand what it is doing.

Alternatvely we could all hand everything over to AI and find a new job.

It is scary how many people have asked me about setting up a business based on AI generated business apps.

4 Likes

We are talking about SQL, not coding your entire app. Of course you should understand what it's doing, but AI is the future. It's the modern-day calculator or computer. Not using it will leave you way behind in the coming years.

2 Likes

Not saying dont use it, saying look at the output and understand it so you are not coding blind. Own it, dont be owned.

1 Like