From the course: Database Foundations: Database Management

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create a function

Create a function

From the course: Database Foundations: Database Management

Start my 1-month free trial

Create a function

- [Instructor] Functions take one or more input values, process them and then output some new value. We can use a function to help us navigate the two_trees database and make queries on the data a little bit easier to write. Let's first review the data that's currently stored in the customers and the orders table by running the select statement that I have here in the script on lines four and five. We'll just select everything out of sales.customers and sales.orders. Now the orders information is stored based off of the customer ID. And you can see that in this column right over here. But it's unlikely that any database user will have all of these ID values memorized. When they want to look up orders for a customer they most likely know the company name. The problem is, is that end users will have to do a search first in order to get the appropriate customer ID number for the company that they're interested in. We can streamline this process by creating a function that takes the…

Contents