mysql - SQL 查询中的子字符串

标签 mysql sql database

所以我正在启动 SQL 并且我有以下查询

Select * from Material where theme = 'math' or name = 'math';

据我所知,这为我提供了在主题或名称上实际具有确切字符串“math”的值。如果我想要该值,即“数学”也作为属性主题或名称的子字符串,我该如何放置。

最佳答案

最简单的方法是使用 LIKE 运算符进行通配符匹配:

 WHERE theme LIKE '%math%'  // math appears anywhere in the string
 WHERE theme LIKE 'math%'   // math appears at the START of the string
 WHERE theme LIKE '%math'   // math appears at the END of the string

关于mysql - SQL 查询中的子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23703705/

相关文章:

mysql - 连接具有相同列号和名称的两个表

mysql - 在 SQL Select 中将值设置为列名称

sql - 在 Oracle SQL Developer 中创建新数据库和新连接

sql - 检查列中不同值的优化方法

sql-server - SQL Server DISTINCT 和 GROUP BY 仍然返回重复项(子查询格式)

php - 我如何在这些多个表中使用sql计数?

php - 如何在php中格式化时间

php - PCF - 不允许应用程序在 MySQL 中创建表

php - Magento销售报表查询

c# - 从 DbDataReader 读取数据最快的方法是什么?