SQL query builder
Pick columns, a WHERE test and an ORDER BY, and see the SQL and the rows it would return from a small pets table.
A database table is rows and columns. SELECT chooses the columns, FROM names the table, WHERE keeps only the rows that match, and ORDER BY sorts them.
This page has a small pets table built in. It writes the SQL for you and shows what the query would return; it does not run a real database.
Things to try
- Untick everything except name and species. How does the SELECT line change?
- Set WHERE species = cat. Which pets are left?
- Set WHERE age > 2 and ORDER BY age DESC. Who is first?
- Type a word for the age. Why does the page complain?