1
I have a variable of type Character Varying(17) and I need to separate one of the characters, for example the third letter, and use it to filter.
For example:
SELECT *
FROM fnord
WHERE terceira(illuminati) = "a"
1
I have a variable of type Character Varying(17) and I need to separate one of the characters, for example the third letter, and use it to filter.
For example:
SELECT *
FROM fnord
WHERE terceira(illuminati) = "a"
2
I think the simplest will be (using the 3rd letter hint):
SELECT *
FROM fnord
WHERE substr('illuminati', 3, 1) = 'a'
The first parameter is a string
that you want to validate, 2º is the index and 3º is the number of characters you want to "remove" (is optional).
Browser other questions tagged sql postgresql where
You are not signed in. Login or sign up in order to post.
Only one detail: the third parameter if unspecified is equivalent to all the remaining characters of the string. See: http://sqlfiddle.com/#! 17/9eecb/18657
– William John Adam Trindade
Right, so I indicated that it would be optional.
– João Martins