7 hours 36 minutes
welcome to model for sequel programming to and this module. We're going to go a little deeper into the sequel program and go over some new concepts and then also mix in some of the older concepts with the newer concepts
and to start off. Where were We are moving into Lesson one sequel functions on The first question you probably have is what is a function, while a function is basically a section of code that serves a specific purpose now this code,
when you're using my Sequels included functions is abstracted out of your view.
That is, you don't have to worry about the code that's been written that produces that function. You just need to, ah, know that it works and trust that it works and then apply it where you need it in your own code. Further on in this lesson, we will actually write our own functions that we can use in our queries as well. But first off,
we're are going to start off with the functions that are included
in my sequel. We're gonna start off with some easy examples. We're gonna use a couple of variations of functions. We're not gonna go over every function because there are a lot of them. However, I will show you how to use some of the more common ones and some scenarios in which you might want to use them. So with that said, Let's go get Let's go ahead and get started.
We're actually going to be using the employees database
that we established on a previous lesson. So go ahead and write. Click that and set that to your active database. If it is not set to your active database and we're going to be working with the employees data table, and if we click on that, we look at the data in here. We'll see that we have a first name and a last name,
and we don't have a full name like we did in the other database
in the schematic a database. If you recall, they have the first and last name and then also a full name.
So let's go ahead and produce a query that creates a full name for us.
So we're going to select.
I don't know what I want that so I'm just gonna drop down to the front field from employees
and we don't need to make any restrictions here, so just go ahead and run. That what? First we need to say what Collins we want to say. See? And I'm gonna say everything, and I'm gonna indicate that with a star
and there is everything.
Now we're going to go ahead and just append to this square by putting a comma, and we're going to call the can cat function. And the comm can't function is a function that pens, strings or tax together.
So, for example, if we say
that's the name of the function. This function takes two arguments. Now the arguments are separated with a comma. So, for example, if I put first name
is the first argument
and then last name only one comma
as the second argument, we will see a result that is a combination of these
two strings or tax added together. So
let me give it an alias as full name. Go ahead and name it.
Let's go in and run this.
I'm sure enough it can. Captain ate it. You can't meet him. Them together
Now we're gonna have Thio actually call this function twice when we use this on the actual data table to cat these two things together. Let me show you what I'm talking about. So we're gonna go ahead and switch this first name.
Actually, we're going to get rid of both East Fields and we're gonna do it. How? You will see in a lot of places. And that's last name. First name. So first, let's put in the last name
and we need to. Captain ate the
Once you've contaminated the Kama, let's go out and run that. Make sure that's still working
and we have the first or the last name with the common. So that's correct.
Now they can. Cat in my sequel does something really neat.
Not a lot of, ah programming languages let you do this. Sometimes it's set up this way and it's nice when it is. We can actually just add and other arguments we could say, Comma,
we can put in the
and now we can run this
on. There we go. We have a full name last name, comma space, first name,
just like you put on the cat function. Now let's say you were in a scenario because I don't believe this works in every database where that wouldn't work, you couldn't just add on another argument. The function was set for two arguments. That's all you could use.
How would we could plead that? Would it would it now be impossible? Um, and the answer is no. It wouldn't be what we would do as we do actually call the cap function again.
We would treat this right here
as its own object or string off text, because that's what this turns into. Its kind of useful to think of it as data that is bubbling out. So when this query runs, it's going to run this part First. This part is going to become text. Then that is going to be passed into the outer one,
where it is then going to be inserted back into the function and called again.
So let's go ahead and put a comma and close off that function call,
and let's just, uh, let's go ahead and finish it off. We'll put in the first name again.
So we are opinion the comma here
in this function that's going to become text, and then once that text results, we're going to send it back into the cat function and attach the first name and we're gonna call. This column is full name. Now. We did accomplish step before by just adding another
argument into it. And my Sequels. Cat function allows you to do that, which is really neat feature. But this is how you would accomplish the same thing if you couldn't do that. Because it is common to find functions where you can't just add extra arguments.
So let's see if this works the same way.
And sure enough, it did. We got the full name. We used the cat function twice,
um, which, uh, gave us the full name field that we were looking for.
So this was a brief intro and two functions.
So I hope you got the king Can't function of working for you. And the next lesson will take a look at some other useful functions. And I hope to see you there. Thank you.
Penetration Testing and Ethical Hacking
The Penetration Testing and Ethical Hacking course prepares students for certifications, like CEH. This course ...
7 CEU/CPE Hours Available
Certificate of Completion Offered
This free course introduces the student to intermediate concepts found in the implementation and application ...
10 CEU/CPE Hours Available
Certificate of Completion Offered