0
0
SQLquery~30 mins

SELECT specific columns in SQL - Mini Project: Build & Apply

Choose your learning style9 modes available
Selecting Specific Columns from a Database Table
📖 Scenario: You are working with a small bookstore database. The database has a table called books that stores information about each book available in the store.Your task is to learn how to select only certain columns from this table to see just the information you need.
🎯 Goal: Build SQL queries step-by-step to select specific columns from the books table.
📋 What You'll Learn
Create a table called books with columns id, title, author, and price.
Insert three specific rows into the books table.
Write a SQL query to select only the title and author columns.
Write a SQL query to select only the title column.
💡 Why This Matters
🌍 Real World
Selecting specific columns is useful when you only need certain information from a database, like showing just names and prices on a website.
💼 Career
Database professionals often write queries to retrieve only the needed data to improve performance and clarity.
Progress0 / 4 steps
1
Create the books table and insert data
Write SQL statements to create a table called books with columns id (integer), title (text), author (text), and price (decimal). Then insert these three rows exactly:
(1, 'The Great Gatsby', 'F. Scott Fitzgerald', 10.99), (2, '1984', 'George Orwell', 8.99), (3, 'To Kill a Mockingbird', 'Harper Lee', 12.50).
SQL
Need a hint?

Use CREATE TABLE to define the table and INSERT INTO to add rows.

2
Select the title and author columns
Write a SQL query to select only the title and author columns from the books table.
SQL
Need a hint?

Use SELECT title, author FROM books; to get only those columns.

3
Select only the title column
Write a SQL query to select only the title column from the books table.
SQL
Need a hint?

Use SELECT title FROM books; to get only the book titles.

4
Complete the project with both queries
Make sure your SQL code includes the table creation, data insertion, and both SELECT queries: one selecting title and author, and the other selecting only title.
SQL
Need a hint?

Check that all parts are included: table creation, inserts, and both SELECT queries.