使用like运算符显示数据

时间:2019-01-10 11:33:39

标签: sql sql-server

我需要设置一个条件,使我的描述列包含使用like运算符的sql server中的以下数据。

Transfer Group from 'GEUC Service Desk' to 'GEUC Tier 2 Security'

请让我知道这个条件

样本数据

Ticket No   Description
1234        Transfer Group from 'GEUC Service Desk' to 'GEUC Tier 2 Security'
5464        Transfer Group from 'GEUC Service Desk' to 'GEUC Tier 2 Security'
5534        No Transfer
7677        No Transfer

在这里,我需要显示说明栏包含Transfer Group from 'GEUC Service Desk' to 'GEUC Tier 2 Security'

的票证

3 个答案:

答案 0 :(得分:0)

我认为您会使用update

update t
    set transfer_group = 'GEUC Tier 2 Security'
    where transfer_group = 'GEUC Service Desk';

答案 1 :(得分:0)

使用<resultMap id = "result" type = "Staff"> <result property = "id" column = "ID"/> <result property = "name" column = "USER_NAME"/> <result property = "phone" column = "PHONE_NO"/> <result property = "email" column = "EMAIL_ADDRESS"/> </resultMap>

LIKE

但是如果这是该列的整个值,则可以使用select * from tablename where description like '%Transfer Group from ''GEUC Service Desk'' to ''GEUC Tier 2 Security''%'

=

答案 2 :(得分:0)

要从Mysql中的'转义,您可以使用\或'。您可以使用以下方法解决问题:

SELECT * FROM yourTable WHERE Description LIKE '%Transfer Group from \'GEUC Service Desk\' to \'GEUC Tier 2 Security\'';

OR:

SELECT * FROM yourTable WHERE Description LIKE '%Transfer Group from ''GEUC Service Desk'' to ''GEUC Tier 2 Security''';