MySQL·MySQL from first query to production

Select and filter

Project columns, filter rows and sort results predictably.

Beginner 13 min read Lesson 2 of 300 Challenge included
What you will be able to do
  • Prefer explicit columns over SELECT *.
  • Use IS NULL, not = NULL.
  • Use LIMIT with ORDER BY for pagination.
  • Add a unique tie-breaker to stable sorts.

In plain English

SELECT chooses columns, WHERE filters rows before grouping and ORDER BY sorts the result. Use explicit columns in application queries and always add a unique tie-breaker when paginating.

select.sqlSQL
SELECT title, minutes
FROM lessons
WHERE minutes >= 15 AND course_slug = 'css'
ORDER BY minutes DESC, title ASC
LIMIT 20 OFFSET 0;
Your turn

Filter and sort

Easy

Select the title and minutes of lessons longer than 20 minutes, longest first.

SQL · starter
SELECT title, minutes FROM lessons
Check your understanding before moving on.
Knowledge checkQuestion 1

Which clause filters individual rows?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Joins
Lesson 2 of 300 · 0% of course