From the course: SQL Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Logical operator OR

Logical operator OR - SQL Tutorial

From the course: SQL Essential Training

Logical operator OR

- Now let's look at a scenario where we would have to employ the OR operator in our response to a request. Management at WSDA music would now like us to get all invoices whose billing city starts with P or the billing city starts with D. Either one of these would satisfy the criteria. Now let's go down to our current criteria and replace it to reflect our current ask. We want to get the billing city so let's specify that field. So the billing city that starts with a P. Now, because this is a partial search we want to include our like operator and we are searching a text field. So we surround that in single quotes and we want the cities that start with P and we don't care what comes after. And that calls for our wild card character which is placed after the P. This is effectively going to give us all billing cities that begin with P. We're also interested in billing cities that start with a D. So either or of these…

Contents