Choosing Columns
Only what you need.
Helen is making a price list for her website. She doesn't need the stock level, or the year it was published. Just the title and the price. So instead of the star, we name the columns we want.

- Helen needs a price list
- Only titles and prices
- Name the columns you want
Pick two columns
After select, we write the column names, separated by a comma. Title, comma, price. Then from books, on the next line. Putting each part on its own line makes it easier to read. Run it. Now we get all thirty books, but only the two columns we asked for. That's much easier to read.
SELECT title, price
FROM books;โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโ โ title โ price โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโค โ The Silent Orchard โ 14.99 โ โ Code of the River โ 12.99 โ โ Stars Over Lagos โ 9.99 โ โ A Short History of Bread โ 19.99 โ โ Python for Curious Minds โ 34.99 โ โ The Last Lighthouse โ 13.99 โ โ Running on Empty โ 15.99 โ โ Dragons of Ember Bay โ 17.99 โ โ The Quiet Kitchen โ 24.99 โ โ Numbers Don't Lie โ 21.99 โ โ Moonlight Express โ 11.99 โ โ Garden of Small Things โ 8.99 โ โ SQL in a Weekend โ 29.99 โ โ The Map Maker's Daughter โ 18.99 โ โ Five Minute Habits โ 12.99 โ โ Crown of Ash โ 16.99 โ โ Spice Roads โ 27.99 โ โ Startup Stories โ 19.99 โ โ Murder at Mill Lane โ 10.99 โ โ Deep Water โ 13.49 โ โ Letters to Lisbon โ 10.49 โ โ Empires of Salt โ 22.99 โ โ Data for Everyone โ 31.99 โ โ The Calm Mind โ 14.49 โ โ The Glass Forest โ 18.49 โ โ One Pan Dinners โ 21.49 โ โ The Pricing Game โ 23.99 โ โ The Painted Door โ 12.49 โ โ Night Train to Oslo โ 14.99 โ โ Wild Coast โ 11.49 โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโ
You choose the order
The columns come back in the order that you write them. Here we ask for price first, then title, then author. Run it. Price is now the first column. You're in charge of the layout. We've also added limit four at the end, which we'll explain in the next lesson.
SELECT price, title, author
FROM books
LIMIT 4;โโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโ โ price โ title โ author โ โโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโค โ 14.99 โ The Silent Orchard โ Mira Hale โ โ 12.99 โ Code of the River โ Tom Avery โ โ 9.99 โ Stars Over Lagos โ Ada Obi โ โ 19.99 โ A Short History of Bread โ Lena Fox โ โโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโ
Small rules that save you
A few small rules will save you from errors. Separate columns with commas, but don't put a comma after the last one. Spell the column name exactly as it is in the table. And capital letters don't matter for the keywords. Select in capitals, or in lower case, both work. Most people write keywords in capitals, so they stand out.
Summary
Now you can pick exactly the columns you need, in the order you like. Next, how to see just a few rows, so big tables don't flood your screen.
Key takeaways- Name the columns you want
- Separate with commas
- Order is up to you