Tricky SQL questions on Strings | Like Operator | Substring Function | CHARINDEX | IQBees

Publicado em: 05 Junho 2021
no canal de: IQBees
4,704
131

Hello Friends,

Most commonly asked question is about Strings in SQL ( Like Operator, Substring , CharIndex ). I think most of the people knows about these. But this question is quite tricky ..if we are good at basics we will be able to crack.

Question : Write a SQL query to find the Name where Second position of the character should be an vowel (a,e,i,o,u ) ?
Ans: SELECT * FROM EmployeeData
WHERE Name LIKE '_[aeiou]%';

You can also achieve the same by substring, charindex. Use substring in case of multiple words search

LIKE operator is used in a WHERE clause to search for a specified pattern in a column

CHARINDEX function searches for a substring in a string, and returns the position. If the substring is not found, this function returns 0.

substring :Required. The substring to search for
string: Required. The string to be searched
start: Optional. The position where the search will start (if you do not want to start at the beginning of string). The first position in string is 1

Syntax
CHARINDEX(substring, string, start)

Substring : Function extracts some characters from a string.

Syntax : SUBSTRING(string, start, length)

string Required. The string to extract from
start Required. The start position. The first position in string is 1
length Required. The number of characters to extract. Must be a positive number

If you need personal help in SQL, Mock interviews, You can contact me

Regards,
IQBees

Tricky SQL questions on Strings | Like Operator | Substring Function | CHARINDEX | IQBees

#SQL #SQLQuery #SQLInterviewQuestion

sql interview questions,sql faq,sql interview questions and answers,IQBees,Tricky SQL questions on Strings,Like Operator,Substring function,CHARINDEX,substring syntax,substring interview questions,sql query,sql tutorial,interview questions sql,tricky interview questions sql strings,top sql interview questions, like operator in sql server, pattern matching


Nesta página do site você pode assistir ao vídeo on-line Tricky SQL questions on Strings | Like Operator | Substring Function | CHARINDEX | IQBees duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário IQBees 05 Junho 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 4,704 vezes e gostou 131 espectadores. Boa visualização!