What does \ (backslash) mean in an SQL query?

后端 未结 2 1852
无人共我
无人共我 2020-12-17 03:16

I have the following query

SELECT txt1 FROM T1 WHERE txt1 LIKE \'_a\\%\'

will that result in answers that have any char+a+\\+whatever?

2条回答
  •  臣服心动
    2020-12-17 03:27

    The LIKE clause allows you to find text when you don't know the exact value, such as names beginning with JO would be

    LIKE 'JO%'
    

    However, if you are search for something ending with a%, then you need to tell SQL to treat the % as part of what you are searching for. In your example, you are looking for a 3 character string, you don't care what the first letter is, but has to end with a%.

提交回复
热议问题