Introduction
In this project, you will learn how to convert the standard body temperature from Celsius to Fahrenheit and round it down to the nearest whole number using SQL statements in the MySQL client.
👀 Preview
MariaDB [(none)]> SOURCE /home/labex/project/Fahrenheit.sql;
+---------------------------+
| Standard Body Temperature |
+---------------------------+
| 99 |
+---------------------------+
1 row in set (0.000 sec)
🎯 Tasks
In this project, you will learn:
- How to access the MySQL database using the
sudocommand without any password - How to write an SQL statement to convert the standard body temperature of 37 degrees Celsius to Fahrenheit
- How to round the Fahrenheit temperature down to the nearest whole number
- How to save the SQL statement in a script file and run it in the MySQL client
🏆 Achievements
After completing this project, you will be able to:
- Understand the conversion between Celsius and Fahrenheit for body temperature
- Write SQL statements to perform basic data manipulation tasks
- Run SQL scripts in the MySQL client to execute SQL statements
- Demonstrate your understanding of SQL and database management concepts
Access MySQL
In this step, you will learn how to access the MySQL database using the sudo command without any password.
- Open a terminal on your system.
- Start the MySQL service by running the following command:
sudo service mysql start
- Access the MySQL client by running the following command:
sudo mysql
You should now be able to access the MySQL database without a password.
Convert Standard Body Temperature to Fahrenheit
In this step, you will learn how to write an SQL statement to convert the standard body temperature of 37 degrees Celsius to Fahrenheit and round it down to the nearest whole number.
- Open the
Fahrenheit.sqlfile. - Write the following SQL statement:
SELECT CAST(98.6 AS SIGNED) AS 'Standard Body Temperature';
This statement converts the standard body temperature of 98.6 degrees Fahrenheit to an integer by rounding down to the nearest whole number and sets an alias as 'Standard Body Temperature'.
Run the SQL Script
In this step, you will learn how to run the SQL script you created in the previous step.
- In the MySQL client, run the following command to execute the SQL script:
MariaDB [(none)]> SOURCE /home/labex/project/Fahrenheit.sql;
This will execute the SQL statement in the Fahrenheit.sql file and display the result.
You should see the following output:
+---------------------------+
| Standard Body Temperature |
+---------------------------+
| 99 |
+---------------------------+
1 row in set (0.000 sec)
The output shows that the standard body temperature of 98.6 degrees Fahrenheit has been rounded down to the nearest whole number, which is 99 degrees Fahrenheit.
Summary
Congratulations! You have completed this project. You can practice more labs in LabEx to improve your skills.



