Wednesday, June 24, 2009

Searching a field in sql table

string username=""; //username string
string useremaipart=""; //email string

// for selecting username's
-->select username from table1 where username like'%" + username+ "%'

// for selecting emailid's
-->select username from table1 where SUBSTRING(email,1,CHARINDEX('@',email)-1) like'%" + useremaipart+ "%'

No comments:

Post a Comment