Print Standard Body Temperature in Fahrenheit

MySQLMySQLBeginner
Practice Now

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 sudo command 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

Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL mysql(("`MySQL`")) -.-> mysql/BasicKeywordsandStatementsGroup(["`Basic Keywords and Statements`"]) sql(("`SQL`")) -.-> sql/BasicSQLCommandsGroup(["`Basic SQL Commands`"]) sql(("`SQL`")) -.-> sql/DataManipulationandQueryingGroup(["`Data Manipulation and Querying`"]) sql(("`SQL`")) -.-> sql/AdvancedDataOperationsGroup(["`Advanced Data Operations`"]) mysql/BasicKeywordsandStatementsGroup -.-> mysql/source("`External Code Execution`") sql/BasicSQLCommandsGroup -.-> sql/select("`SELECT statements`") sql/DataManipulationandQueryingGroup -.-> sql/in("`IN clause`") mysql/BasicKeywordsandStatementsGroup -.-> mysql/select("`Data Retrieval`") sql/AdvancedDataOperationsGroup -.-> sql/cast("`CAST functions`") subgraph Lab Skills mysql/source -.-> lab-301378{{"`Print Standard Body Temperature in Fahrenheit`"}} sql/select -.-> lab-301378{{"`Print Standard Body Temperature in Fahrenheit`"}} sql/in -.-> lab-301378{{"`Print Standard Body Temperature in Fahrenheit`"}} mysql/select -.-> lab-301378{{"`Print Standard Body Temperature in Fahrenheit`"}} sql/cast -.-> lab-301378{{"`Print Standard Body Temperature in Fahrenheit`"}} end

Access MySQL

In this step, you will learn how to access the MySQL database using the sudo command without any password.

  1. Open a terminal on your system.
  2. Start the MySQL service by running the following command:
sudo service mysql start
  1. 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.

  1. Open the Fahrenheit.sql file.
  2. 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.

  1. 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.

Other MySQL Tutorials you may like