我希望搜索文章:
SELECT *
FROM articles
WHERE `body` LIKE `%src="http://%"
但是我想要除外:
src="//example.com"
src="//media.example.com"
我尝试:
SELECT *
FROM `articles`
WHERE `body` LIKE '%src="http://%' AND
`body` NOT LIKE '%src="http://example.com%' AND
`date_show` >= '2018-06-24'
LIMIT 20
但是我得到错误的结果。我该如何正确执行此操作?
答案 0 :(得分:2)
SELECT * FROM `articles` WHERE `body` LIKE '%src="http://%'
and `body` not in (SELECT body
FROM `articles` where `body` NOT LIKE '%src="http://example.com%' ) AND
`date_show` >= '2018-06-24' LIMIT 20;