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
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
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%';
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