我是SQL新手,有問題。我想從我的數據庫中刪除任何描述欄中有人標籤「#whatever」的地方。我能寫出下面的查詢:如何在SQL中使用LIKE函數,但是要使用確切的單詞?
select id from table where description_field LIKE "%#whatever%" and user_id=333
但是,如果我在這裏使用LIKE功能,將刪除無論它#whatever的比賽,但我擔心它可能會刪除一些地方有#whateverANDthis。
我該如何編寫一個刪除行的查詢,只要它在描述中包含「#whatever」,而不是其他變體,如「#whateverANDthis」或「#whateverORthis」。
我想刪除它說:
「我有這麼多的樂趣#whatever」
但不是:
「我有這麼多的樂趣#whateverAndWhatever」
您是否在'description_field'中存儲了多個標籤? –
@juergend是的,所以一個人可以在他們的描述中有多個標籤。 – ariel
[在MySQL中搜索「全字匹配」]的可能重複(http://stackoverflow.com/questions/656951/search-for-whole-word-match-in-mysql) – Carth