> For the complete documentation index, see [llms.txt](https://brianwu.gitbook.io/brian/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brianwu.gitbook.io/brian/zi-liao-ku/mysql/zi-chuan-bi-dui.md).

# 字串比對

## 消除重複值

原先可能會查到多筆相同資料

```
SELECT city FROM UsrData;
```

增加 DISTINCT

`SELECT DISTINCT city FROM UsrData;`

即可排除重複部分

參考資料: ( <http://mark-freefox.blogspot.tw/2011/07/sql_16.html> )

## 排除掉不要的字

原先搜尋想要的字

```
SELECT city FROM UsrData WHERE city LIKE '%value%';
```

排除掉不要的字則加上 NOT

```
SELECT city FROM UsrData WHERE city NOT LIKE '%value%';
```

參考資料: LIKE (Entity SQL) (<https://msdn.microsoft.com/zh-tw/library/bb399359(v=vs.110).aspx>)
