24

I have one table called STUDENT. In this table there are two columns, ID and NAME. I want to retrieve all rows from this table where name starts with 'ab' and ends with 'k'. What is the SQL query for doing this?

pconcepcion
  • 5,591
  • 5
  • 35
  • 53
jaleel
  • 1,169
  • 8
  • 22
  • 46

3 Answers3

41

I think you are looking for something like:

SELECT ID, NAME FROM STUDENT WHERE NAME LIKE 'ab%k';

For wildcard operations you should use a WHERE clause with the LIKE keyword that allows you to filter columns that match a given pattern using the %symbol as a wildcard.

There is a question about the List of special characters for SQL LIKE clause that has a good list of LIKE special characters

pconcepcion
  • 5,591
  • 5
  • 35
  • 53
3

its like if you are looking for find name start with H and end with F just write query.

select emp_name from employee_test where emp_name like 'H%F';
Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
Hanif Khan
  • 31
  • 2
2
select ID, Name from student where name like 'ab%%k'