包含URL的SQL查询

时间:2017-02-06 11:12:36

标签: sql sql-server

我有下面的查询。我想接收不包含mywebsite.com/url但包括mywebsite.comurl的记录:

SELECT COUNT(*) 
FROM [mydb].[dbo].[mytable] 
WHERE No is not null 
AND Thumbnail is not null 
AND Thumbnail not like '<a target=\"_blank\" href=\"http://www.mywebsite.com/%'

当我运行查询时,它会给我一个意外的数字。查询有什么问题,如何使其正常工作?

1 个答案:

答案 0 :(得分:3)

 SELECT COUNT(*) FROM [mydb].[dbo].[mytable] WHERE No is not null
 AND Thumbnail is not null
 AND Thumbnail like '%mywebsite.com%'
 AND Thumbnail not like '%mywebsite.com/url%'