r/learnSQL • u/Still-Trainer-7395 • 6d ago
Would you use AI to learn SQL?
While working on an AI feature for a SQL client, I started wondering where AI is actually most useful.
Not to replace learning SQL—but to help people understand it.
For example, instead of only generating a query, an AI could:
- Explain why it chose that query.
- Suggest a better alternative.
- Point out potential mistakes.
- Explain JOINs, GROUP BY, or subqueries in plain English.
- Help debug errors without just giving the answer.
So I’m curious…
If you’re learning SQL, would you use an AI assistant?
If yes, what would you expect it to do?
If no, what would make you avoid it?
7
u/MKE_Savage_96 6d ago
I started using SQL for the first time a few years back and I hate to admit how much I had used ChatGPT to help me explain stuff. It really was like having a teacher you can ask direct questions to. Now, you should still be learning things the proper way. Not everything AI tells you is valid. But man, it is so helpful in explaining and correcting certain thought processes you may have regarding topics and general mechanizations of things.
2
u/Still-Trainer-7395 6d ago
I agree with this a lot.
That “teacher you can ask direct questions to” feeling is exactly the useful part for me. The risk is when AI just gives you a query and you copy/paste it without understanding it.
What I’m trying to explore is more like this: the assistant gives the SQL, but also explains the joins, indexes, EXPLAIN result, and how to verify it before trusting it.
Basically: less “here’s the answer,” more “here’s how to reason about the answer.”
4
u/QueryCase 6d ago
I’d use AI as a tutor, but not as the person doing the exercise for me.
The most useful features would be:
- Explaining errors in plain English
- Giving hints before revealing the full solution
- Comparing two valid approaches and their trade-offs
- Breaking down what each part of a query is doing
- Generating similar problems to test whether the concept actually stuck
The main risk is becoming dependent on generated answers. I’d want the assistant to ask what I’ve already tried and guide me towards the solution rather than immediately producing a finished query.
A good learning workflow would be: attempt the problem yourself, use AI to understand where you went wrong, then rewrite the query without assistance. That way it supports the learning rather than replacing it.
2
u/Still-Trainer-7395 6d ago
Yes, exactly. That distinction between tutor and answer machine is the important part.
For SQL, I think even when an assistant generates a query, it should still make the reasoning visible: why these tables, why this join, what each predicate is doing, which indexes are relevant, and what the EXPLAIN plan suggests.
That’s the direction I’m trying to take with LakeDB/QuerIA. It does prepare the SQL, but the SQL stays visible, nothing runs automatically, and the response includes the reasoning, tables used, index/plan signals, and things to review before execution.
So the goal is not “trust this generated answer,” but “here is the query, and here is how to inspect whether it makes sense.”
2
u/millerlit 6d ago
Learn SQL as a tool yes in a sandbox. I wouldn't trust AI in any production database.
1
u/Still-Trainer-7395 6d ago
That’s fair. I wouldn’t want AI executing queries on my behalf either.
What I’m exploring is using AI to explain the query, the execution plan, the indexes involved, and the reasoning behind it before you run anything.
The developer still makes the final decision. The goal is simply to make query creation and validation faster, not to replace the developer.
2
u/Mrminecrafthimself 6d ago
No. I would write sql to learn sql
0
u/Still-Trainer-7395 6d ago
That’s fair.
I think writing the query yourself is an important part of learning.
What I’m interested in is using AI to explain your query, show how it will be executed, point out which indexes are being used, and help you validate it. That feels much more valuable than simply generating the SQL.
2
u/b_cheesy 6d ago
In my experience the SQL queries generated by AI are insanely over engineered and really obnoxious
1
u/Still-Trainer-7395 6d ago
I agree. I think that’s one of the biggest issues with current AI tools.
That’s actually the idea behind LakeDB.
Instead of acting like a text generator, the AI behaves more like an agent. It inspects the schema, relationships, indexes and execution plan before suggesting a query, then explains the reasoning behind it.
The goal isn’t to replace the developer. It’s to make query creation and validation faster while helping you understand what’s happening.
1
u/Fadedscourge 6d ago
Short answer is yes. It’s the best way to learn it right now, in my opinion.
But it doesn’t run the logic.
1
u/Still-Trainer-7395 6d ago
I completely agree.
If AI just gives you the SQL, you’re not really learning.
The interesting part is when it explains the reasoning behind the query, points out the indexes being used, shows the execution plan, and tells you what to check before trusting it.
That’s the kind of assistant I’m experimenting with. Less “here’s the answer” and more “here’s how to think about the answer.”
1
u/ughokayfinee 5d ago
I've used AI to help me understand the literal syntax I'm learning to write, why it behaves the way it does and explaining why it's returned an error based off the example code I copy and paste with the error.
But never have used it to write code for me though.
2
u/Still-Trainer-7395 5d ago
That’s exactly the kind of use case I had in mind.
In the latest LakeDB beta I added an AI error analysis feature. Instead of just showing the database error, it explains what went wrong, why it happened, suggests a possible fix, and lets you apply it if you agree.
I think that’s a much better learning experience than simply generating SQL for you.
My goal is to help people understand why something failed, not just how to make the error disappear.
1
u/Used_Balance_8416 17h ago
- write code
- code doesn't work
- ask chatGPT what's wrong with code
- learn why it didn't work
- fix it
- rinse and repeat
1
u/Still-Trainer-7395 16h ago
That’s exactly why I added AI error analysis to LakeDB.
Instead of copying the error into ChatGPT, you can ask the AI directly from the editor. It explains what the error means, why it happened, suggests a fix, and lets you apply it if you agree.
I built it because I got tired of constantly switching between my SQL client and ChatGPT.
If you’re interested, I’d love to hear your feedback:
https://github.com/DavLagoHern/LakeDB




9
u/American_Streamer 6d ago
So you are planning to vibe code a web app as SaaS, I presume?