SQL query to select the records where name start with some specific character.

Abhisek
Posted by Abhisek under Sql Server category on | Views : 8499
SELECT name,roll FROM Student WHERE name LIKE 'AB%'


It will display the records in which the name starts with AB.

Comments or Responses

Posted by: Pandians on: 3/1/2010 Level:Silver | Status: [Member] [MVP]
Hi

Greetings

The query will perform only MAXIMUM 3 Characters in [name] column, not for Morethan THREE characters...

It should be...
SELECT [name],roll FROM Student WHERE [name] LIKE 'AB%'

Please change the query / question

Cheers

Posted by: Puneet20884 on: 3/3/2010 Level:Bronze | Status: [Member]
You mentioned "It will display the records in which the name starts with AB."

But it will display the records in which the name is AB_.

Please modify your query to
the one suggested by Pandians
as

SELECT [name],roll FROM Student WHERE [name] LIKE 'AB%'

in order to fetch what is mentioned !!
Posted by: Abhisek on: 3/3/2010 Level:Bronze | Status: [Member]
Thanks for your correction. It is posted by mistake. Sorry for the mistake.

Login to post response