Inverse of SQL LIKE '%value%'

后端 未结 3 719
眼角桃花
眼角桃花 2021-02-04 19:48

I have a MySQL table containing domain names:

+----+---------------+
| id | domain        |
+----+---------------+
|  1 | amazon.com    |
|  2 | google.com    |
         


        
3条回答
  •  春和景丽
    2021-02-04 20:11

    You could use a bit of SQL string manipulation to generate the equivalent of string.EndsWith():

    SELECT * FROM table WHERE  
    substring('www.google.com',
    len('www.google.com') - len([domain]) ,
    len([domain])+1) = [domain]
    

提交回复
热议问题