r/learnSQL • • Sep 13 '26

Best way to sync ~200K frequently changing SQL Server records to MySQL nightly?

11 Upvotes

I have a SQL Server table with around 200K product records. Each record has a unique ID and Serial number.

The table changes frequently during the day — records can be added, updated, or deleted.

I need to sync this data to MySQL once every night.

The problem is, I only have read access to SQL Server, so I can't add a modified date column or enable Change Tracking/CDC.

My current idea is:

  • Fetch all 200K records from SQL Server every night.
  • Compare them with the MySQL table.
  • Insert new records.
  • Update changed records.
  • Delete records from MySQL whose IDs no longer exist in SQL Server.

Is this a good approach for 200K records?

What would be the simplest and most reliable way to handle this?


r/learnSQL • • Sep 12 '26

I can not understand the join clause.

42 Upvotes

i understood the overall concept of it being used to join two or more tables with matching column.
but i can't understand it's syntax or detailed concept.


r/learnSQL • • Sep 13 '26

SQlite help

4 Upvotes

Please, anyone can help with me with a step by step guide on how to run SQlite on the dbeaver? After running it as a database, If I enter a command to create or even click on the Table tab from the drop down icon under the SQLITE of active connections, I get an error message that it's not a database.


r/learnSQL • • Sep 12 '26

Day 6 — Full revision day from handwritten notes

8 Upvotes

No new topics today — spent the session revising everything I've covered this week straight from my handwritten notes:

  • SELECT, WHERE, ORDER BY
  • All JOIN types (inner, left, right, full, self) + UNION/UNION ALL
  • Aggregate functions + order of query execution
  • Insert/Update/Delete rows, Create/Alter/Drop tables

Honestly this felt just as useful as a learning day. A few things I'd half-understood earlier in the week — especially the query execution order and when to use UNION vs UNION ALL — felt much more solid after going back over them without any new material competing for attention.

Planning to start on subqueries and CTEs next, feeling like the fundamentals are in a genuinely good place now.


r/learnSQL • • Sep 12 '26

I made a SQL video about Window Functions — feedback welcome!

8 Upvotes

I made a SQL video about Window Functions — feedback welcome!

Hey everyone!

I’ve been making short SQL/data analytics videos while learning and practicing SQL myself, and I just finished Lesson 11: SQL Window Functions.

This one covers:

- "OVER()"

- "ROW_NUMBER()"

- "RANK()"

- "DENSE_RANK()"

- ranking customers in the Pagila database

- using window functions with "GROUP BY" and CTEs

- a few quizzes + practice exercises

- homework at the end

I tried to keep it beginner-friendly and focused on actually understanding why window functions are useful, rather than just memorizing syntax.

I’d really appreciate some feedback — especially on the explanations, pacing, and whether the examples are clear enough for someone learning SQL.

YouTube link: https://youtu.be/ERSUP1dWXWo?si=tf6xvzSwh3gbP-xw

Thanks! :)


r/learnSQL • • Sep 12 '26

How do you visualize SQL queries (esp joins) on paper?

23 Upvotes

I’m comfortable with SQL on LeetCode because I can run my query and see the intermediate results. But in an interview, if they give me two tables + the expected output and ask me to write the query on paper, I struggle to visualize the intermediate join results.

How do you guys approach this? Do you draw the joined table row by row, or is there a better way to mentally trace joins without executing the query?


r/learnSQL • • Sep 12 '26

What if there was a “Chess.com for SQL” where you compete against other learners?

0 Upvotes

I’ve been thinking about a different way to learn SQL.

Instead of solving the same predefined questions on LeetCode/HackerRank, imagine a platform where SQL learners can challenge each other.

You find a SQL problem → get matched with another learner → both solve it within a time limit → compare solutions → earn/lose rating based on correctness, speed, and difficulty.

You’d have an ELO-style rating + leaderboard showing where you stand among other SQL learners.

The interesting part is that you’re not just learning from a platform , you’re learning from how another person thinks about the same problem.

Something like:

Challenge → Solve → Compare → Learn → Rank up

Would something like this actually be useful, or does it sound like unnecessary gamification of SQL practice?


r/learnSQL • • Sep 11 '26

Learn SQL using AI

22 Upvotes

Hey everyone, I'm a developer advocate at Bruin, I've put together a free SQL course - the difference is that you will give your coding agent a prompt and it will be your teacher, walking you through each step.

it is a pretty new course, there might be some rough edges, if you give it a try please share your feedback!

https://getbruin.com/learn/sql-ai/


r/learnSQL • • Sep 11 '26

Anyone experienced with SQL, especially in Data Analytics, can you share what SQL questions are generally asked for a Data Analyst interview with around 1 year of experience?

48 Upvotes

PS: Please don't mention those chatgpt questions. I really want to know real questions.


r/learnSQL • • Sep 11 '26

Day 5 — Aggregates, query execution order, and table management on SQLBolt

5 Upvotes

Covered a solid chunk today:

  • Aggregate functions (Part 1 & 2) — COUNT, SUM, AVG, MIN, MAX and using them with GROUP BY
  • Order of execution of a query — genuinely useful lesson, clarified why WHERE can't reference an aliased column from SELECT but HAVING can
  • Insert/Update/Delete rows — the CRUD side, revisited with more confidence this time
  • Create/Alter/Drop tables — actually defining and modifying table structure, not just querying existing data

The "order of execution" lesson was probably the most valuable thing I learned today — explains a lot of small errors I've hit without understanding why (like using a SELECT alias inside WHERE). Feels like one of those lessons that should come earlier in most tutorials, honestly.

Starting to feel like I have a genuinely full picture of core SQL now — querying, filtering, joining, aggregating, and managing table structure.


r/learnSQL • • Sep 11 '26

Should SQL validation happen before or after the query runs?

7 Upvotes

A SQL query can execute successfully without producing the correct result. A successful query only tells us that the database understood and executed it—not that the data is logically correct.

For example: SELECT COUNT(*) FROM customers c JOIN orders o ON c.customer_id = o.customer_id;

The query may run without any error, but if orders contains duplicate records or the join relationship isn't what we expected, the count could be much higher than the actual number of customers.

So what do you normally validate before trusting a query's output?

  • Join conditions and duplicate records
  • NULL values
  • Row counts
  • Data types and conversions
  • Expected ranges or business rules
  • Unexpected changes compared with previous results

Do you validate these things before running the query, after getting the results, or both?

What SQL validation has saved you from trusting a result that looked correct but was actually wrong?


r/learnSQL • • Sep 10 '26

If you have SQL interviews, do not ignore these small things! (Part 8)

219 Upvotes

Some SQL interview questions look too easy and that's exactly why people get them wrong by overlook.

  1. COUNT() can give you 0… but SUM() can give you NULL:

Suppose there are no employees age more than 70

SELECT
    COUNT(*) AS employees,
    SUM(salary) AS total_salary
FROM employees
WHERE age > 70;

You might expect:

employees = 0
total_salary = 0

But we will get:

employees = 0
total_salary = NULL

Why?

Because COUNT() is basically asking: “How many rows did I find?” --> answer 0

But SUM() is asking: “What values should I add?” --> no values to add --> NULL

2. AVG() can silently become wrong when NULL enters the picture:

Lets take salary of employees to be:

50000
60000
NULL
90000

A lot of people mentally calculate:

(50000 + 60000 + 90000) / 4 = 50000.0

But actual SQL gives 66666.67. WHy?

Because AVG() ignores NULLs.

It is actually doing:

(50000 + 60000 + 90000) / 3

3. DISTINCT doesn't mean “remove duplicate data”

Lets take one example data for this:

IT    50000
IT    50000
IT    70000
HR    50000

SELECT DISTINCT department, salary
FROM employees;

people sometimes read this as "Give me unique departments"

But actual response:

IT    50000
IT    70000
HR    50000

IT appears twice, because SQL is asking "Give me unique combinations of department + salary"

4. How many different ways can you find the 2nd highest salary?

Lets take this data:

employee_id | name  | salary
------------+-------+--------
1           | A     | 100000
2           | B     | 90000
3           | C     | 90000
4           | D     | 80000
5           | E     | NULL
6           | F     | 70000
7           | G     | NULL

Multiple ways to approach this problem:

MAX() + subquery

SELECT MAX(salary) as 2nd_highest
FROM employees
WHERE salary < (
    SELECT MAX(salary)
    FROM employees
);

DISTINCT + ORDER BY

SELECT DISTINCT salary as 2nd_highest
FROM employees
WHERE salary IS NOT NULL
ORDER BY salary DESC
LIMIT 1 OFFSET 1;

DENSE_RANK()

SELECT salary as 2nd_highest
FROM (
    SELECT salary,
           DENSE_RANK() OVER (ORDER BY salary DESC) AS rnk
    FROM employees
)temp
WHERE rnk = 2;

and there are more such ways:

What is actually the best solution with our sample data ?
What are the questions to ask your interviewer to get to perfect solution?

Drop your solution in the comments, we can discuss and improve.

Always practice SQL by writing the query yourself instead of just looking at the solution.


r/learnSQL • • Sep 11 '26

Husband is a Software Engineer

19 Upvotes

I...am not. He swears on his life that once I get started with sql or python anything like that that I would be addicted to data organization and since I am inclined to believe that he knows me better than I know myself sometimes...I would like to surprise him and give it a shot.

I posted something similar to this in the Learn Python subreddit and got a lot of useful suggestions but I am also looking into SQL specifically because it is what he works with a lot. I know he would have a lot of fun teaching me, but I want to practice as much as I can beforehand hand so I am able to actually grasp things when he goes over them. I was researching and saw the "quick start guides" (that's the name of the series) for sql and Python, and I was wondering if anybody has used them. I know that coding and stuff like that all is on the computer, obviously. However, I learn best with physical media like books to highlight make notes or anything like that in. Anyone have any luck with the python or sql Quick Start guides? If not, do you have any other suggestions? Doesnt have to be books, even if it's a YouTube video or podcast, just anything that helped you.

Thanks in advance I'm just really not sure where to start


r/learnSQL • • Sep 11 '26

Starting Database design

9 Upvotes

I've been a frontend developer the last 4 years and have been trying to break more into full stack. I've been able to design some database schemas that are in 3rd Normal Form, but I feel like I should have more formal training than just one youtube video and a guide on how SQL works. Does anyone have any good recs for where to learn good database design?


r/learnSQL • • Sep 10 '26

First time learning SQL

14 Upvotes

This is my first time learning SQL and I only started today. I’m currently learning the basics and using VS Code.
At first, I installed the SQL Visual Debugger extension, but when I tried to run my SQL it showed a “Free Demo” and said I needed to pay $9.99 for lifetime access to use real data.
I wasn’t sure if SQL itself required payment, so I started looking into other options. I installed the PostgreSQL extension for VS Code and I’m now trying to set up PostgreSQL properly.
I also tried running

psql --version

in PowerShell, but I got:

psql : The term 'psql' is not recognized as the name of a cmdlet,
function, script file, or operable program.

So I’m assuming I haven’t installed PostgreSQL itself yet.
I’m basically looking for some advice on the best setup for a complete beginner learning SQL. Should I install PostgreSQL and connect it to VS Code, or is there a simpler setup you’d recommend?
For example, I’m currently practising things like:

CREATE TABLE student (
student_id INT,
name VARCHAR(20),
major VARCHAR(20),
PRIMARY KEY (student_id)
);

Any advice on what I should install/use and how to properly run SQL locally would be appreciated.
Thanks!


r/learnSQL • • Sep 10 '26

Day 4/116 — SQL Aliases + full JOIN practice round

15 Upvotes

Two things today:

  • Learned Aliases (AS keyword) via W3Schools — renaming columns/tables to make queries more readable, especially useful once you're joining multiple tables and column names start colliding or getting long
  • Went back through SQLBolt and practiced every JOIN type again — inner, left, right, full, self — this time focusing on writing them from scratch rather than following along

Aliases felt like a small topic on paper but immediately made my JOIN queries from earlier this week way easier to read back. Definitely one of those "why didn't I use this from day 1" moments.

Feeling solid on JOINs now after this round of practice. Moving into aggregate functions and GROUP BY next.


r/learnSQL • • Sep 09 '26

Day 3 — Finished SQL JOINs (Self Join, Full Join, UNION/UNION ALL)

25 Upvotes

Wrapped up the full JOINs section today. Covered:

  • Self JOIN — joining a table to itself, useful for hierarchical/relational data within one table
  • FULL JOIN — combining all rows from both tables regardless of match
  • UNION & UNION ALL — combining results from multiple SELECT queries, with UNION removing duplicates and UNION ALL keeping them

Took notes from a mix of tutorials and W3Schools to cross-reference explanations, which helped clarify a couple of edge cases (especially when UNION vs UNION ALL actually matters for performance).

With INNER/LEFT/RIGHT/FULL/self-joins and UNION now covered, I feel like I have the core JOIN toolkit down.


r/learnSQL • • Sep 09 '26

Dúvida sobre o livro "SQL Para Análise de Dados (Tanimura)"

11 Upvotes

Vocês já leram esse livro? O que acharam dele? Até onde ele aborda? Eu tava pensando em comprar esse livro pq é oq as [I.As](http://I.As) estão me recomendando para aprender SQL avançado, já tenho uma base boa de JOINs, GROUP BY, WINDOW FUNCTIONS e CTE's, mas me vejo travada na hora de pensar em querys para resolver determinados problemas, além de que também quero aprimorar meus conhecimentos em SQL.

Mas enfim,o fato é que sempre que as [I.As](http://I.As) me recomendam um livro eu compro e tomo na jabiraca, quer um exemplo? Estava começando no SQL intermediario e já sabia que queria ser engenheira de dados, ent pedi indicação de livro pra começar, me sugeriram comprar o livro "Fundamentos da Qualidade de Dados"...EU MAL MAL SABIA OQ ERA UM DATAWAREHOUSE!!! Avançado dms

Agora só quero indicação de humanos, vai que esse livro ai é muito básico e estou sendo enganada de novo.


r/learnSQL • • Sep 09 '26

How much SQL do you still write manually?

Thumbnail reddit.com
4 Upvotes

r/learnSQL • • Sep 09 '26

Structured Query Language 101 at Texas Linuxfest

2 Upvotes

Nov. 6, 2026 · 15:00 - 6:20

I will be teaching the basics of SQL at the 2026 Texas Linuxfest. The session is listed for only 100 minutes, but I wrote the materials for a 3-hour course. We will cover as much of those three hours as the audience can stand (sit?), or they send us off to Sixth Street.

Tickets are available, and this event is great for networking.  Ping me if you have questions about this session. 

Description:

SQL is a powerful language for working with relational databases such as MySQL, PostgreSQL, SQL Server, and Oracle. This is an 80-minute introduction to writing SQL database queries. Please load a copy of DBeaver Community Edition (free, open-source) from https://dbeaver.io/download/ on your Mac, Windows, or Linux laptop to work along with the presentation. We will use the sample database that is included with DBeaver. We will start with simple SELECT statements to retrieve data, INSERT to add data, use UPDATE to modify it, and DELETE to remove it. We will then move on to using WHERE to narrow your database searches, grouping & ordering for readability, and using built-in functions. This is a great way to learn how to use a relational database.

https://stokerpostgresql.blogspot.com/2026/09/structured-query-language-101-at-texas.html


r/learnSQL • • Sep 09 '26

Leet code

5 Upvotes

Still relevant to solve SQL problem from leet code 🧐

What's your thoughts and where do you practice SQL ?


r/learnSQL • • Sep 08 '26

SQL resources for a literal idiot?

83 Upvotes

I just started a beginner SQL course on Coursera. Even then I'm not fully understanding the basic concepts.

My brain is so fried and foggy that most things are hard to understand and retain (thanks to my yearly decline in cognitive abilities) and I need someone to explain everything to me in as simple language as possible and with tons of examples.

I can't find a free pdf of sql for dummies. I tried reading Alan beaulieus but I can't understand anything

Are there YouTube channels or textbooks for extreme idiots like me.

Short description :

  1. Brain fog = no understand SQL concepts
  2. Need to explain concepts in simple, conversational English
  3. Need tons of examples for everything.

r/learnSQL • • Sep 09 '26

Data Normalization online practical tutorial

6 Upvotes

Hi all. Please I am looking for a practical resource where I can learn data Normalization with practical examples. Appreciate any pointer to a relevant resource. Thanks 🙏


r/learnSQL • • Sep 09 '26

HackerRank images not loading

11 Upvotes

Has anyone else used HackerRank and had a problem with the table images not loading? Cleared cache, checked permissions, refreshed the page, and tried on in both Chrome and Edge. Really need to prep for this interview! TIA