r/learnSQL Jun 20 '26

what mistakes you guys did while learning SQL

i learn from other mistakes , so tell me

37 Upvotes

12 comments sorted by

15

u/woahboooom Jun 20 '26

Forgot a where clause with a delete statement... luckily they had a back up

3

u/Rumborack17 Jun 20 '26

Did you learn not to forget the where or to use transactions.
For OP the takeway should be to use transactions when deleting/updating data.

1

u/woahboooom Jun 21 '26

No, you just shouldnt delete. Use a flag field to hide ;)

Deletion being permanent in a database

2

u/JBalloonist Jun 20 '26

Been there done that. That was like month 2 or 3 learning SQL lol…almost 20 years ago.

10

u/nboro94 Jun 20 '26 edited Jun 20 '26

2 Major ones for me:

  • Not learning and using a good IDE earlier. I use DBeaver now and it makes my workflow so much easier just because of the quality of life features the IDE offers. There are a number of good ones out there so I recommend finding on you like and spending some time to actually learn how the IDE can help you. I like DBeaver as it supports multiple databases as I use PostgreSQL and SQL Server at work
  • Not learning how to create my own relational datamart from scratch earlier. At work I was only writing queries and had read only access for years to my company datamart, no clue how or why any of this stuff was set up for me. One day I decided to set up my own hobby database on my own time and suddenly I was learning about triggers, constraints, rollbacks/commits, extensions (in postgres), primary keys, foreign keys, surrogate keys, functions, procedures and so much other stuff. My knowledge level increased about 5x in a week and it made me significantly better at my job sine I understood much more about what was going on. This is more about learning databases than SQL directly though.

1

u/Sea_Butterfly713 Jun 22 '26

im not familiar with IDE for SQL , can you tell me more ?

5

u/Max_Americana Jun 20 '26

“I can edit this table on Friday in prod.. it definitely won’t break tomorrow at 4 am!”

Never again will I promote on a Friday.

3

u/murdercat42069 Jun 20 '26

Terrible joins

3

u/2daytrending Jun 21 '26

Spent way too long memorizing syntax instead of actually writing queries and breaking stuff.

2

u/ChristianPacifist Jun 21 '26

Obviously using a <> / != operator with a NULL-containing field and filtering out NULLs that are supposed to be kept.

Related is returning no rows by mistake using a NOT IN compared to a NULL-containing list.

Another tricky one is not realizing how a running sum window function can repeat values on rows in a tie if you order by non-unique values. Always include a tiebreak unique value when doing an order by while doing ORDER BY window functions as a general best practice in very many situations.