Filter: OR
string str = "john,jack,alton"; string select = "SELECT * FROM [TableName] WHERE [UserName] LIKE ''%' + REPLACE(str , ',' , '%'' OR [UserName] LIKE ''%') + '%''";
Filter: AND
string str = "john,jack,alton"; string select = "SELECT * FROM [TableName] WHERE [UserName] LIKE ''%' + REPLACE(str , ',' , '%'' AND [UserName] LIKE ''%') + '%''";
ref url:
http://forums.asp.net/t/1683482.aspx?Sql+query+to+search+database+with+multiple+keywords
沒有留言:
張貼留言