How SQL Injection Works

How SQL Injection Works

How one typed line can dump your whole database, and how parameterized queries stop it

What you'll learn

  • How glued-together queries let input become code
  • Why 1042 OR 1=1 returns every row
  • Fixing it with parameterized queries
  • Input checks and least-privilege database users

In this video, we'll look at how SQL injection works, using an order tracking page that builds its query by gluing strings together. We'll see how typing 1042 OR 1=1 turns one order into every order in the table, and why the database ends up reading the user's text as code.

Then we'll fix the bug with parameterized queries, where the query and the values travel separately. We'll finish with two extra habits: checking input and giving your app's database user only the access it needs.

By the end, you'll know how to spot an injectable query and how to write one that's safe.

More videos

30 short explainers so far, with more on the way

View all videos

Join the Community

roadmap.sh is among the top 10 most starred projects on GitHub and is visited by hundreds of thousands of developers every month.

Top 10 out of 28M!

371K

GitHub Stars

Star us on GitHub
Help us reach #1

+90kevery month

+3.2M

Registered Users

Register yourself
Commit to your growth

+2kevery month

52K

Discord Members

Join on Discord
Join the community

RoadmapsGuidesFAQsYouTube

roadmap.shby@nilbuild

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© roadmap.sh·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.