mysql教程:模糊查询之like

[复制链接]
查看2264 | 回复0 | 2020-10-12 21:30 | 显示全部楼层 |阅读模式
模糊查询的条件不能用'=',要使用like。
案例代码如下:
  1. mysql> select * from stu where stuname like 'T_m';
  2. +--------+---------+--------+--------+---------+------------+------+------+
  3. | stuNo  | stuName | stuSex | stuAge | stuSeat | stuAddress | ch   | math |
  4. +--------+---------+--------+--------+---------+------------+------+------+
  5. | s25320 | Tom     | 男       |     24 |       8 | 北京           |   65 |   67 |
  6. +--------+---------+--------+--------+---------+------------+------+------+
  7. 1 row in set (0.00 sec)

  8. -- 查询姓张的学生
  9. mysql> select * from stu where stuname like '张%';
  10. +--------+---------+--------+--------+---------+------------+------+------+
  11. | stuNo  | stuName | stuSex | stuAge | stuSeat | stuAddress | ch   | math |
  12. +--------+---------+--------+--------+---------+------------+------+------+
  13. | s25301 | 张秋丽   | 男     |     18 |       1 | 北京        |   80 | NULL |
  14. +--------+---------+--------+--------+---------+------------+------+------+
  15. 1 row in set (0.00 sec)
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16