前端之家收集整理的这篇文章主要介绍了
Transact-SQL:如何标记字符串?,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望能够从文本框中
标记化输入字符串以进行
查询.
示例:
用户在文本框中输入“abc xyz 123”.
我想做这个:
SELECT * FROM database WHERE Name contains "abc" AND "xyz" AND "123"
-- as opposed to containing "abc xyz 123"
-- please ignore my sql Syntax,I am an absolute beginner
谢谢.
使用字符串拆分
功能(例如,像
this one),您可以使用以下
内容:
SELECT t.*
FROM atable t
INNER JOIN dbo.Split(@UserInput,' ') s ON t.Name LIKE '%' + s.Data + '%'
原文链接:https://www.f2er.com/mssql/78428.html