sql server - How to concatenate row values for use in WHERE clause of T-SQL query -
i want write query in t-sql perform search on 2 concatenated columns. 2 columns fname , lname. here have far:
select fname, lname, ... users join othertable on foo=bar fname+' '+lname '%query%'
sql server doesn't syntax, though. how structure query can perform operation searches through 2 concatenated columns, allowing me search user's full name, rather first name , last name individually?
i can suggest 1 of fname or lname null fails., (null concat null)
try
... isnull(fname, '') + ' ' + isnull(lname, '') '%query%'
however, use computed column , consider indexing because run awfully.
Comments
Post a Comment