Introduction
In this challenge, you'll leverage your SQL skills to query specific data within an SQLite database named treasure.db. The goal is to retrieve a hidden artifact by crafting a SELECT statement that filters results based on the artifact's id.
You'll connect to the database, write a query to select the name column from the artifacts table, and use a WHERE clause to identify the artifact with an id of 2.
Query Specific Data in SQLite
A valuable artifact is hidden in the database. Your mission is to retrieve it using your SQL skills.
Tasks
- Write an SQL query to find the
nameof the artifact with theidequal to 2 from theartifactstable in thetreasure.dbdatabase.
Requirements
- Connect to the SQLite database named
treasure.dblocated in the~/projectdirectory using thesqlite3command. - Write a
SELECTstatement to retrieve thenamecolumn. - Use a
WHEREclause to filter the results based on theidcolumn. - The query must be executed within the
sqlite3shell. - Save the output to a file named
/home/labex/project/result.txt.
Examples
Executing the correct query should output:
cat /home/labex/project/result.txt
Placeholder
Hints
- Remember to specify the database file path correctly.
Summary
In this challenge, the task involves querying a specific artifact name from an SQLite database named treasure.db. The database contains a table named artifacts with columns id, name, and description. The goal is to retrieve the name of the artifact where the id is equal to 2.


