具有多个LIKE条件的SQL ESCAPE

时间:2015-04-21 20:35:35

标签: sql sql-server

我想为多个LIKE条件指定相同的转义字符。哪个是对的?

SELECT * FROM [table] WHERE [column1] LIKE 'value1!%'            AND [column2] LIKE 'value2!%' ESCAPE '!'
SELECT * FROM [table] WHERE [column1] LIKE 'value1!%' ESCAPE '!' AND [column2] LIKE 'value2!%' ESCAPE '!'
SELECT * FROM [table] WHERE [column1] LIKE 'value1!%' ESCAPE '!' AND [column2] LIKE 'value2!%'

还是别的什么呢?

1 个答案:

答案 0 :(得分:1)

你的第二项是正确的:

SELECT * FROM [table] WHERE [column1] LIKE 'value1!%' ESCAPE '!' AND [column2] LIKE 'value2!%' ESCAPE '!'