SQLTeam.com | Weblogs | Forums

Searching a text in four columns

sql2008
sql2008r2

#1

Hello
I have four columns of mobile number stored in database,such as Phone No,Mobile No,Home No, Home Mobile No.

Now i want search the given number(search number) in all the four columns and retrieve the particular record (only one).

Some columns may have repeatedly same number in 2 columns and some columns may be empty.

In the above columns some numbers stored as 12345678 OK,12345678 Driver.

I want to search only first 8 digit in any column

Further quires awaited.

Thanks


#2
select *
  from yourtable
 where phoneno like '12345678%'
    or mobileno like '12345678%'
    or homeno like '12345678%'
    or homemobileno like '12345678%'
;