Search icon CANCEL
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn SQL using MySQL in One Day and Learn It Well

You're reading from  Learn SQL using MySQL in One Day and Learn It Well

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781836205678
Pages 121 pages
Edition 1st Edition
Languages
Author (1):
Jamie Chan Jamie Chan
Profile icon Jamie Chan

View

 

Now that we have created the tables and inserted some data, we are ready to select data from our tables.

 

Specifically, we’ll create a view that shows us all the booking details of a booking.

 

If you refer to the bookings table created previously, you can see that it lists the id, room_id, booked_date, booked_time, member_id, datetime_of_booking and payment_status of each booking.

 

What if in addition to the information above, we are also interested to know what each of the room ids stand for? For instance, we may want to know what AR stands for. In addition, what if we also want to know the price of each room?

 

In order to obtain these information, we have to refer to the rooms table.

 

To simplify this process, we are now going to write a SELECT statement to combine the two tables into a single view. This view displays the id (from the bookings table), room_id, room_type, booked_date, booked_time, member_id, datetime_of_booking...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}