Operator LIKE on SQL Server used in a WHERE clause to search for a specified pattern in a column.
SELECT ColumnName(s) FROM TableName WHERE ColumnName LIKE pattern
Example 1:
select StudentName from (
select ('Wardana Putra')StudentName union
select ('Raihana Pratiwi') union
select ('Juliana Eka Putri') union
select ('Joko Susanto') union
select ('Sugeng Joko Utomo')
)v0 where StudentName like 'J%'
#Results:
StudentName
Juliana Eka Putri
Joko Susanto
Example 2:
Still use Example 1 with small modification.
select StudentName from (
select ('Wardana Putra')StudentName union
select ('Raihana Pratiwi') union
select ('Juliana Eka Putri') union
select ('Joko Susanto') union
select ('Sugeng Joko Utomo')
)v0 where StudentName like 'i%'
#Results:
StudentName
Juliana Eka Putri
Raihana Pratiwi
Example 3:
Still use Example 1 with small modification.
select StudentName from (
select ('Wardana Putra')StudentName union
select ('Raihana Pratiwi') union
select ('Juliana Eka Putri') union
select ('Joko Susanto') union
select ('Sugeng Joko Utomo')
)v0 where StudentName like '%ana%'
#Results:
StudentName
Juliana Eka Putri
Raihana Pratiwi
Wardana Putra
Tidak ada komentar:
Posting Komentar