Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First create a practice database, then add 2 new tables, customers and orders, each table should have primary keys auto - increments defined. Then, answer

First create a practice database, then add 2 new tables, customers and orders, each table should have primary keys auto-increments defined.
Then, answer each question below by providing a screenshot of the query and the output results.
1) Create a table customers with the following 4 fields id, first_name, last_name, email. Make sure the id is set as a primary key. Provide a query.
2) Create a SQL query to create a new table called "orders" with the following columns:
order_id (integer, primary key)
customer_id (integer, foreign key referencing id in the customers table)
order_date (date)
order_total (decimal)
3) Write a query to insert a new record into a MySQL database using the INSERT statement. Provide a query.
4) Write a query for selecting all columns from a table named "customers" in a MySQL database using the SELECT statement. Provide a query.
5) Write a query for selecting only the "first_name", "last_name", and "email" columns from the "customers" table. Provide a query.
6) Write a query for updating an existing record in a MySQL database using the UPDATE statement? Provide a query.
7) Insert a few test records into table orders with various order_totals (10.38,55.07 and 100.50). Note: the customer_id should match the id defined in the customers table. Provide a query.
8) Write a MySQL query that selects all rows from two tables "customers" and "orders" where the user's ID matches the order's user ID. Return the user's first name, last name, and the order's total price. Provide a query.
9) Write a MySQL query that selects all rows from two tables "customers" and "orders" where the user's ID matches the order's user ID and total price is more than 50. Return the user's first name, last name, and the order's total price. Provide a query.
10) Write a query for removing a singe record or multiple records from a MySQL database using the DELETE statement? Provide a query.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions