From the course: SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
More advanced string functions - SQL Tutorial
From the course: SQL: Data Reporting and Analysis
More advanced string functions
- [Instructor] Recently, we've used left and right to return parts of string from the beginning or end, respectively. But what if you wanted to return a partial string from the middle? Here we could use substring unless you're using Oracle, in which case you need substra. Substra works in all of the four versions except Microsoft. So none of them work across the board. Anyway, we're going to use substring. Select substring, first name, and this one takes three arguments. 1,1, like that. To get the first letter of the first name, we give the field name then the starting character one, not zero. And then the length, the number of characters we want to return. So this should return us the same as left, 1 returns us, and you can see it does 'cause there's our P. Now let's play around with this a little bit. What if we tried 1,2, then we'd have PE for Penelope instead of P because we've said that we still want to start…
Contents
-
-
-
-
Retrieve data with SELECT5m 31s
-
(Locked)
Filter results with the WHERE clause5m 4s
-
(Locked)
Use LIKE, IN, and wildcards with WHERE5m 39s
-
(Locked)
Sort SQL results with ORDER BY1m 42s
-
(Locked)
Use string functions on your data6m 41s
-
(Locked)
More advanced string functions8m 35s
-
(Locked)
Change report headings with an alias2m 28s
-
(Locked)
Use date functions with WHERE8m 50s
-
(Locked)
Challenge: Query a table1m 7s
-
(Locked)
Solution: Query a table1m 23s
-
(Locked)
Challenge: Convert case50s
-
(Locked)
Solution: Convert case2m 30s
-
-
-
-
-