使用等于运算符进行完全匹配-
select *from yourTableName where yourColumnName=yourValue;
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> FirstName varchar(100), -> LastName varchar(100) -> ); mysql> insert into DemoTable values('John','Doe'); mysql> insert into DemoTable values('Chris','Brown'); mysql> insert into DemoTable values('Carol','Taylor');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
这将产生以下输出-
+-----------+----------+ | FirstName | LastName | +-----------+----------+ | John | Smith | | John | Doe | | Chris | Brown | | Carol | Taylor | +-----------+----------+ 4 rows in set (0.00 sec)
以下是在MySQL表中搜索特定字符串的查询-
mysql> select *from DemoTable where LastName='Doe';
输出结果
这将产生以下输出-
+-----------+----------+ | FirstName | LastName | +-----------+----------+ | John | Doe | +-----------+----------+ 1 row in set (0.00 sec)