r/learnSQL • u/Gullible_Heart_5153 • Jun 15 '26
Anyone else struggle with SQL
Hello
For some reason I find SQL hard and I need to know if that’s the case for anyone else? I’ve only been doing this for 8 months. And I’m struggling. Any tips you can provide would be most helpful, thank you.
I can write basic queries. I struggle with Joins for some reason. That’s a basic thing. Please help.
Update: thank you everyone!! For all your words of encouragement. I appreciate it. I’m excited to continue to learn SQL. I was feeling defeated when I initially posted this and a lot of you have uplifted me.
79
Upvotes
37
u/dumi_007 Jun 15 '26
LEFT JOIN and INNER JOIN are your north star
80% of all SQL scripts I've written over last 15 years have needed LEFT or INNER joins.
10% were CROSS JOINS.
The other 9.9% were anti JOINS but that's more method than keyword.
0.01% were other JOINS
Master those 2 and know when to use UNION vs UNION ALL and you are ready to combine tables
6
u/Better-Credit6701 Jun 15 '26
It can get complicated especially when you throw in hundreds of tables and worse when there often aren't FKs. Working on a database that was built for insert speeds and lacks many indexes. I've worked on some stored procedures that were a 1,000 lines long.
Be sure to think in sets using temporary tables for large data sets and CTEs for smaller data sets. A set would be one temp table, breaking the problem down and working with the least amount of data you can think of.
4
u/cush2push Jun 15 '26
I also have been struggling with multiple Joins
what has helped me is making individual CTEs when and where I can to allow a singular join through majority of it all now
4
u/Ramenshark1 Jun 15 '26
SQL was the absolutely most mind fuck thing I studied in college. It come naturally to some people but I was never built to think that way. I also had the same struggles.
Funnily enough I got hired for a sql role strait out of college, for the last year all Ive done is Oracle sql, it does get easier but I STILL struggle with joins sometimes. Im also one of those guys dealing with stored procedures calling more stored procedures with 1000+ lines of code cursors triggers you name it. Right now I have to rebuild some of these and hating my life but I am improving a little bit every day. Its lame to say but its all about practice, if you work more then the person who naturally "gets" sql you will eventually be better (assuming they dont work at it at shit ton too), its all about exposure and practice and reps. Same is true for anything.
1
u/equilni Jun 15 '26
Would be helpful to know what exactly you are struggling with? Just JOINs?
1
u/Mrminecrafthimself Jun 15 '26
What exactly are you struggling with regarding JOINs? Is there a particular moment where you get stuck?
Is it deciding what field(s) to join on? Is it deciding which type of JOIN to use? That info can help us give you targeted help
1
u/Acceptable-Sense4601 Jun 17 '26
People are fighting so hard to not use Ai to write queries as if anyone is going to care that you can do it from scratch
3
u/shine_on Jun 15 '26
Tables are joined on common data items. on a simple level, if you have a CustomerID in two tables, that's what you use to join the tables. Most tables are joined to other tables on only one common column. Think of them like a simplified map of the country, with the tables being cities and the joins being roads that connect them. If you want to get from CityA to CityB there might be a road linking them directly, or you might have to go through CityC first.
3
u/TepiTepic Jun 16 '26
Its all about visualising it. For example, there are website that can draw databases and table, and for me, that should be the first thing to learn, once you are good at drawing the conexión between Keys (primary Keys and foreing keys) and understanding them, you can go ahead and draw conexión on join.
2
u/ExcitementPopular482 Jun 15 '26 edited Jun 15 '26
Remember set and venns?...well joins are like that,two circles A and B.with a common overlap in the middle, left outer join(takes all the data from A and the common factors of B) right outer join( all of B with the common factors of A) full outer join is the whole thing except the common,inner join is only the common factors of A and B. There is more too it than that but that a basic understanding of the concept,at least an easy one I can think of and I'm not great at SQL either
2
u/tmk_g Jun 16 '26
You're definitely not alone. A lot of people struggle with SQL at first, especially joins, so don’t beat yourself up over it. Try practicing joins on small tables first, and think of them as matching rows between tables instead of memorizing syntax. Sites like SQLBolt, StrataScratch, and Mode are great places to practice. With enough repetition, joins will start to feel a lot less confusing.
2
u/nikkiinit Jun 16 '26
If you’re struggling with sql, I made a full tutorial on joins, here is the link:
SQL Tutorial for Beginners | Complete SQL Course 2026 (Beginner to Advanced)
https://youtu.be/MnEfq_Hi_uo
Go to 1:46:50 for join explanation. Join may seem complicated but once you grasp the concept, you’ll be fine. Hope this helps.
2
u/[deleted] Jun 18 '26
I have been learning SQL recently take help of AI alot throw all weird questions ask more questions then only you can tackle a question in more ways. Basically you need to end up with every worst case it could deliver that's how you can think and keep checks at every line of query. Go by execution order on how to get the required data. Joins were frustrating for me as well but I did some how visualize with GEMINI or claude it will help alot you will find patterns to do
1
u/DonJuanDoja Jun 15 '26
Nah SQL is my safe place, where everything makes sense and does exactly what I tell it to do. Joins have always made sense to me.
It’s honestly more about understanding the data and its structure/relationships than the syntax. You have to know exactly what you have and what you want it to be, if you know that then the sql is easy, sql can and will do nearly anything you want, I’ve made it write dynamic html code.
It’s the most powerful tool I have, just be happy you’re learning it.
1
u/sql_powerbi2921 Jun 15 '26
I understand basics but never know when a CTE is required or a sub query or use a union all.
Just building bigger scripts baffle me alot
1
u/hannorx Jun 16 '26 edited Jun 16 '26
I had a similar challenge visualising joins at the start. It helped when I started to think of joins in terms of algebraic sets instead of procedural thinking (which my brain naturally defaults to, as I am trained as a software engineer).
https://www.cuemath.com/algebra/sets/
1
u/yinkeys Jul 16 '26 edited Jul 16 '26
DM. I can give you the structured learning steps from noob to expert, including cheat sheets, flow charts, questions etc
STEPS
SQL GAME SITES
http://mystery.knightlab.com https://lost-at-sql.therobinlord.com/ https://exercism.org https://sqlprotocol.com
And more
1
u/Cautious-Ad5067 Jul 17 '26
Joins tripping people up is extremely common, even well past 8 months in — it's usually not that the concept is hard, it's that most explanations teach the syntax before the mental model, so you're pattern-matching instead of actually picturing what's happening.
The mental model that usually unlocks it: for every single row in your left (first) table, SQL goes looking for matching rows in the right table based on your
ONcondition. AnINNER JOINonly keeps rows where a match was found on both sides. ALEFT JOINkeeps every row from the left table no matter what, and just fills inNULLfor the right side if no match exists. That's really the whole difference — inner join is "only pairs that matched," left join is "everything on the left, plus whatever matched on the right."A common trip-up: people forget that a join can multiply your row count if there are multiple matches on the right side (e.g., one customer with five orders joined to the orders table gives you five rows, not one) — that's not a bug, it's the join working correctly, but it surprises people the first few times because they expected one row per customer.
If a visual helps more than words: search "SQL join Venn diagram" — seeing inner/left/right/full as overlapping circles makes the "which rows survive" question click for a lot of people much faster than reading definitions.
The good news: joins are one of those skills where once the mental model clicks, it clicks completely and stays clicked — it's much more of a "sudden click" skill than a gradual one, so don't read the struggle as a sign you're behind.
1
u/Mrminecrafthimself Jun 15 '26 edited Jun 16 '26
Think of it like this…
You have a spreadsheet in excel. There are multiple tabs with different datasets on them. Your main tab, and then tabs with different sets lookup values. Your main data has ID #s which correspond to ID #s in the lookup tabs.
If you were going to take your customer ID from your main sheet and find the customer’s name and DOB from the “customers tab,” how would you do that manually? How would you find that customer in the customer tab?
You’d take the customer ID from your main sheet, then you’d go to the customer tab and find the same ID. When you find it, you’d grab their name and DOB. That’s what a JOIN does.
So if you want to JOIN main tab with customers tab, you JOIN ON customer_id
Now - if you don’t find a specific customer ID in the customer tab, do you want to remove their entry from the main sheet or do you want to keep it and just leave their name and DOB blank? The first is an INNER JOIN - only return records which are present in both tables. The last is a LEFT JOIN - if I records are found in table 2, keep the record from table 1 but print the fields from table 2 as NULL.
Now let’s say you have another lookup tab of orders – the product(s) purchased, their amounts in units, their total price, the customer, and their dates…but you don’t have the order number. How would you identify the appropriate order from that tab that corresponds to a record in your main tab? You could filter for orders on a specific date, then filter for orders of a specific product, then filter for orders of a specific amount, then filter for orders from a specific customer ID…all until you get a unique record that matches your row on the main tab.
By finding the unique combination of fields that identifies a specific order, you’ve created what’s known as a “business key.” That translates in sql to a JOIN like this…
SELECT …
FROM my_table t
LEFT JOIN orders o
ON t.customer_id = o.customer_id
AND t.order_date = o.order_date
AND t.product_id = o.product_id
AND t.total_units = o.total_units
0
u/Ifuqaround Jun 16 '26 edited Jun 16 '26
If you're still struggling with joins after 8 months I'd say perhaps SQL is not for you. Almost anyone can write a basic select, from and where statement.
8 months is a long time to not understand joins.
I'm not trying to make you feel defeated or give up. In reality it's a long time to learn joins.
Are you actually working with SQL in a position or just doing it for learning/funsies?
I'm in this space. You either don't have the talent or you're just not putting in the time. If I hired you, I'd expect you to understand them within a certain amount of time with our data. 8 months is too long.
SQL isn't for everyone. Don't get your heart set on some sweet remote job.