Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select Statement

Author  Topic 

soori457
Yak Posting Veteran

85 Posts

Posted - 2008-02-02 : 00:08:50
How to select a name only containing three characters in a Table

Please help me

Thanks in Advance



Suresh Kumar

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-02 : 00:11:26
Can you explain in detail what you are trying to achieve with some sample data & reqd o/p ?
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-02 : 00:17:25
Maybe?

select * from table where name like '???'
Go to Top of Page

soori457
Yak Posting Veteran

85 Posts

Posted - 2008-02-02 : 01:41:25
EmpName

Suresh
Karteek
Kiran
Raj
Ram
Chandu
Lee
Kranthi
Ravi

In EmpName Coloumn, I have those data.Now I want to retrieve EmpName with three characters only.
i.e., The O/P should be

EmpName

Ram
Raj
Lee

Now tell me, How to write select Statement for that

Suresh Kumar
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-02 : 02:00:50
left(EmpName, 3)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-02 : 02:15:23
or
substring(EmpName,1,3)
Go to Top of Page

soori457
Yak Posting Veteran

85 Posts

Posted - 2008-02-02 : 02:30:37
select * from table where name like '___'
This Query is working

Is there any other way to retrieve data with three characters only.

Suresh Kumar
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-02 : 02:43:09
select * from table where left(EmpName,3) =.....

or
select * from table where substring(EmpName,1,3) =.....


please make your requirement clear with some sample data and expected o/p if you wish to receive quick solution.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-02 : 04:14:17
select * from table where len(lastname) = 3



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -