如何使这个工作?
SELECT Concat(city, ' ', location, ' ', location2) as src1
FROM locations
WHERE src1 LIKE '%var%'
答案 0 :(得分:0)
如何使用 + cocantenation运算符
SELECT city + ' ' + location + ' ' + location2 as src1
FROM locations
WHERE city + ' ' + location + ' ' + location2 LIKE '%var%'
查看+ (String Concatenation) (Transact-SQL)
或者您可以使用子选择
SELECT *
FROM (
SELECT city + ' ' + location + ' ' + location2 as src1
FROM locations
) vals
WHERE vals.src1 LIKE '%var%'
或者使用Sql Server 2005+,您可以使用WITH
语句
;WITH vals AS(
SELECT city + ' ' + location + ' ' + location2 as src1
FROM locations
)
SELECT *
FROM vals
WHERE src1 LIKE '%var%'
答案 1 :(得分:0)
SELECT Concat( city, ' ', locatio`n, ' ', location2 ) as src1 FROM locations WHERE Concat( city, ' ', location, ' ', location2 ) LIKE '%var%'`
将起作用