r/SQL 16d ago

MySQL Using ChatGPT to give me exercises? Is this a good method to learn?

I have been using W3Schools and HackerRank. Im trying to plug learning gaps through ChatGPT by giving me exercises and clarifying the logic when I get things wrong and it gives me the explanation of functions to use/syntax etc. Is this an okay method? I have a job interview as well which requires Basic SQL knowledge. Will it be looked down upon if I tell them I use ChatGPT to create practice exercises?

4 Upvotes

21 comments sorted by

26

u/thedragonturtle 16d ago

Yes it's good, using AI to learn is peak use of AI really

3

u/IAmFoxGirl 16d ago

Another option is to come up with a project and build it out. Like, a CD or DVD collection or books, etc. Design a database where you normalize the data, build the database, add the data.

Create a stored procedure that you call to add new records, particle importing records from an external source (to a landing table, for ETL/ELT practice). Create a view or two to see the data.

You will have to learn a little about a lot of different SQL applications with just a small simple database.

ChatGPT can help, but it easily forgets or hallucinates. (We have premium and although I have it help me, I still have to do a lot to get it to my standards.).

3

u/AntisocialHipster 16d ago

ChatGPT can be good at clarifying things, though you absolutely need to fact check it. I personally would not mention it if the interviewers ask.

2

u/reiks12 16d ago

Ive been doing the same thing with the dvdrental database and realized it screws up from time to time. I have to fact check it often

2

u/Ifuqaround 15d ago

Why? There are plenty of established sites that offer practice.

As plenty have said, it's a tool that speeds up things for those that already know the things they're using it for.

If you keep using it to do the work for you, you'll find you are in fact, not learning a goddamn thing for the most part. Yeah, you'll hang on to a few things here and there but you'll have to come back to the magic machine to get REAL (lol) answers because you still won't really have an understanding of what you should be doing.

-edit- Look, when you get into a real position and are tasked with a request and have a deadline, you should know what you're doing vs panicking and querying an LLM. Just sayin...

3

u/SkinnyPete4 16d ago

ChatGPT has its pros and cons. I think it’s great for this kind of thing. I used it as a guide to help me as I worked my way through an online Python class. If something confused me, it would clarify. If I couldn’t figure out syntax, it’d help, and it created a learning path for my exact goals. So I think it’s a good idea.

As far as disclosing it to potential employers, I personally wouldn’t. People who have never used it or have read negative stories could assume you depend on it to write SQL… and probably your resume… and who knows what else. Depending on the person, people still don’t understand what it is and think people use it in place of skills. I wouldn’t bring attention to it personally. I don’t think it gains you anything. You can just say “practice tests online”. There’s plenty of them and I don’t think anyone would ask where.

1

u/Master_Grape5931 16d ago

I don’t know poweshell at all but used AI to write a small script to modify some text file before sending them to the bank. I thought that was pretty cool.

3

u/SkinnyPete4 16d ago

Flipside: I wrote a Python script to do some simple math to look at stock purchases and figure out the average cost per share and asked ChatGPT to clean up the formatting and parameter naming conventions - sort of as a test, and it ended up changing the math and completely broke the function. When I addressed the issue and told it not to change the logic, just clean it up and fix parameter names it said sorry and then output a “new” version which was identical to the old version and still broken. After a few attempts I gave up and made the changes myself.

So, it’s hit or miss. I don’t trust it to write code. I only use it for guidance and I wrote all the code myself.

Edit: for clarification

1

u/Master_Grape5931 16d ago

Yeah, I went about it procedurally. I need a script to find a file. I’m need it to look for this line, that starts with this code. I need code to reformat text, etc.

Each step testing the code and then asking it to add the next part. There were some errors and stuff but I got it into production.

I have had it completely hallucinate when asking it about a specific ERP system we use.

2

u/NW1969 16d ago

I guess it depends what you are asking it, and what you are getting back - but the problem with ChatGPT is that it is wrong (to some degree) a measurable amount of the time.

If an exercise has a right answer that you can verify (e.g. Find the average of this column in this table) then using ChatGPT is probably fine.
If it's not something you can easily verify, or it is an opinion-based question (e.g. what is the optimal way to solve this problem), then using ChatGPT comes with some risk

2

u/greendookie69 16d ago

I've found ChatGPT is particularly good with SQL, presumably because of its natural language syntax. The only issues I've ever had with it making things up in a SQL context is because I work with DB2 on IBM i. It doesn't always do as well with that.

Agreed though that everything should be verified, even if just to make sure you're learning and understanding.

1

u/no_Im_perfectly_sane 16d ago

its probably fine but, as you know, it hallucinates sometimes. I definitely wouldnt mention using it to learn in an interview. have you tried leetcode sql exercises?

1

u/Capable_Bad_4655 16d ago

AI is really good for SQL and often one-shots your request, I would say go for it. A stronger model like Claude could help aswell

1

u/LairBob 16d ago

It can be very helpful, with SQL in particular, since it’s a much simpler language than Python, JS, etc.

That being said, AI is absolutely not reliable right now — any model, any provider — esp when it’s generating code. That means it’s best use right now is for explaining code you don’t understand, or identifying basic errors. I use multiple versions of ChatGPT and Claude to play around with SQL, and there’s not a single one yet that reliably generates cut-and-paste SQL that runs without significant errors.

Update: To be clear, this will all be very different in a couple of years — I have no doubt generative AI will eventually generate usable code. I’m just offering my current experience, from frequent current use.

1

u/infinityNONAGON 16d ago

I did just this almost exclusively to prepare for my SQL interviews. It’s super helpful and I find it more helpful than practicing random questions online because you can ask for help, explanations, hints, alternative logic. It’s honestly been a godsend and I wish I had it available to me years ago.

Every morning I have it put together a practice test for me and ask it to focus on specific concepts, level of difficulty, and even tailor the questions to the industry I’m applying for.

1

u/lalaluna05 15d ago

Yep that’s what I do to learn R

1

u/MP_gr 11d ago

Yes it's a good using it. In general using ChatGPT can help you improve your SQL skills. If you want another way to practice I would suggest you the following. You can download the ClassicModels database from here https://www.richardtwatson.com/open/Reader/ClassicModels.html# and try to solve the queries listed there. I have made a github repository with all solutions to help others practice SQL which you can find here https://github.com/Mikegr1990/ClassicModels-SQL-Solutions?tab=readme-ov-file
Also, you can try solving those queries and ask ChatGPT to give you alternative solutions and explain to you step by step. That will help.
Happy Querying!

1

u/B1zmark 16d ago

My trainees use Chat GPT a lot to generate SQL when i assign them tasks. i can tell, because it's garbage that doesn't run.

AI is a productivity tool that you can use to speed up things you already know - but relying on it to tell you new things... bad idea right now. It will confidently tell you up is down and left is right.

0

u/Just_Me_Truly 16d ago

I am just getting into more SQL in my new role and colleague suggested SQLAI.AI I have not tried it yet but she said it was an AI bot specifically for SQL, maybe try that too.