我该如何选择:
SELECT * FROM Street WHERE StreetName LIKE IN ('% Main Street', 'foo %')
请不要告诉我可以使用,OR因为它们实际上来自查询。
OR
没有合并LIKE和IN语法,但是您可以使用LIKE,JOIN如下所示。
LIKE
IN
JOIN
;WITH Query(Result) As ( SELECT '% Main Street' UNION ALL SELECT 'foo %' ) SELECT DISTINCT s.* FROM Street s JOIN Query q ON StreetName LIKE q.Result
或在评论中使用您的示例
SELECT DISTINCT s.* FROM Street s JOIN CarStreets cs ON s.StreetName LIKE cs.name + '%' WHERE cs.Streets = 'offroad'