SQL Tutorial - 42: The LENGTH() & INSERT() Functions

preview_player
Показать описание
In this tutorial we'll learn to determine the length of strings and also to insert strings within other strings through the LENGTH() and INSERT() functions respectively.
Рекомендации по теме
Комментарии
Автор

Hey! I think the correct way is to tell the length of string which you want to remove in third argument so you don't loose characters after it. For example, insert('Hello word from space', 7, 5, 'world') the result will be 'Hello worldfrom space' (space is removed also, because it's in 5th position starting from 7), but after insert('Hello word from space', 7, 4, 'world') result is 'Hello world from space' .

archus
Автор

very well organized video. I have one small question like if i have big string than how do i count position of the letter for sub string. I don't want to count manually. Is there any other way to count? Thanks for creating this tutorial.

ilasuba
Автор

I think the third argument is more of how many characters that need replacement as when you give this query select insert('Hello Word', 7, 2, 'World'): the output is 'Hello Worldrd' and when the third argument is given as 3, the output is 'Hello Worldd' and so on..so if we need to replace the entire word, we need to give in a value >=4(or <0) for third argument.
I am thinking this way and please correct me if I am wrong.

subbudgreat
Автор

About INSERT(): Some people say its a creepy function but I kind of like it.

asimmohammad
Автор

Have you noticed that if you replace the 4 with a -1 you get the same ouput
SELECT INSERT('Hello Word', 7, -1, 'WORLD') -> Hello WORLD

HamsterLoad