黄色电影一区二区,韩国少妇自慰A片免费看,精品人妻少妇一级毛片免费蜜桃AV按摩师 ,超碰 香蕉

MySQL LIKE 子句

mysql like 子句

mysql 數(shù)據(jù)庫使用 sql select 命令來讀取數(shù)據(jù),而且可以通過 where 子句來獲取符合一定條件的記錄。

where 子句中既可以使用等號(hào) = 來設(shè)定精確匹配條件,又可以使用 like 子句設(shè)定模糊匹配條件。

sql like 子句中使用百分號(hào) %字符來表示任意字符,類似于unix或正則表達(dá)式中的星號(hào) *

如果沒有使用百分號(hào) %, like 子句與等號(hào) = 的效果是一樣的。

 

1. mysql like 子句的語法

select field1, field2,...fieldn 
from table_name
where field1 like condition1 [and [or]] filed2 = 'somevalue'
  • 你可以在 where 子句中指定任何條件。
  • 你可以在 where 子句中使用like子句。
  • 你可以使用like子句代替等號(hào) =。
  • like 通常與 % 一同使用,類似于一個(gè)元字符的搜索。
  • 你可以使用 and 或者 or 指定一個(gè)或多個(gè)條件。
  • 你可以在 delete 或 update 命令中使用 where...like 子句來指定條件。

 

2. 通過命令窗口使用 like 子句

以下是我們將 article 表中獲取 author 字段中以 com 為結(jié)尾的的所有記錄:

mysql 范例

mysql> use yapf; database changed mysql> select * from article where author like '%com'; +-----------+---------------+---------------+-----------------+ | id | title | author | submission_date | +-----------+---------------+---------------+-----------------+ | 3 | 學(xué)習(xí) java | yapf.com | 2015-05-01 | | 4 | 學(xué)習(xí) python | yapf.com | 2016-03-06 | +-----------+---------------+---------------+-----------------+ 2 rows in set (0.01 sec)
相關(guān)文章