Search the Blog

Saturday, July 13, 2019

SQL Like operator


SQL LIKE Operator

 Top 100+ Sql Server Interview Questions

 


Sql Query to select similar kind of data which have perticular pattern comman in their specipic data column

Basic Format

SQL Like operato


SELECT col1, col2, ...,columnN
FROM table_name
WHERE columnN LIKE pattern;

Demo-

SELECT * FROM Student
WHERE StudentName LIKE 'a%';

Note:-  Like Operator Consume Maximum Resources


See Complete SQL Tutorial


Search Types Using Like Operator


SELECT col1, col2, .... col_N

FROM table_name WHERE columnN LIKE pattern;


All Students with a column name 'StudentName' that start with "s" in the Second position:
SELECT * FROM Students
WHERE Student_Name LIKE '_s%';
SQL Like opeartor Usage


All Students with a column name 'StudentName' that have "s" in the Third position:
SELECT * FROM Students

WHERE Student_Name LIKE '__s%';

All Students with a column name 'StudentName' that have "s" in the Fourth position:
SELECT * FROM Students

WHERE Student_Name LIKE '___s%';

FROM table_name WHERE columnN LIKE pattern;


All Students with a column name 'StudentName' that start with "s" in the Second position:
SELECT * FROM Students
WHERE Student_Name LIKE '_s%';

All Students with a column name 'StudentName' that have "s" in the Third position:
SELECT * FROM Students

WHERE Student_Name LIKE '__s%';

All Students with a column name 'StudentName' that have "s" in the Fourth position:
SELECT * FROM Students


WHERE Student_Name LIKE '___s%';

No comments:

Post a Comment

Translate