Wednesday, March 21, 2012

hi, i need ur urgent help immediately(!)

i have a sql data table which icludes names and surnames

as like as that:

george read

hasan hujtr

deem greg

ade ad

edy es

-----

i need a "select" query to receive only people whom surnames composed merely two letters(ade ad, edy es).

thanks,

best regards.

Do you mean two letters or two words?

|||

I don't think the length() function is supported in sql server... but a hack for that if you're just looking for 2 letters or less would be:

select *
from names
where substring(surname,0,2) = surname

|||^^^ I do believe that will return surnames of length 1 too though... so try it.|||

Don't mean to spam, but I was wrong... there is a length function...

select *
from names
where len(surname) = 2

|||

thanks for ur helps

best regards.

No comments:

Post a Comment