我想在多列中搜索一个字符串以检查它是否存在于任何列中。我在这里找到了一个解决方案Thorsten
的答案很短,但这是针对 mysql 服务器的解决方案,而不是针对 SQL Server。所以我想在 SQL Server 中应用类似的查询。
这是 Thorsten 建议的查询。
Select *
from tblClients
WHERE name || surname LIKE '%john%'
Run Code Online (Sandbox Code Playgroud)
我试过了
/* This returns nothing */
Select *
from Items
Where ISNULL(Code, '') + ISNULL(Code1, '') = '6922896068701';
Go
/* This generate error Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '|'.
I also used this one in mysql but it does not show the exact match.
*/
Select *
from Items …Run Code Online (Sandbox Code Playgroud)