mysql - LIKE 与 SUBSTR 一起使用时不返回任何记录
问题描述
我有两张桌子:
教练生涯
coach_id | start | end
483368 2017-01-01 NULL
比赛季节
coach_id | name
483368 2017/2018
我写了查询:
SELECT * FROM coach_career cr
INNER JOIN competition_seasons s
ON SUBSTR(cr.start, 1, 4) = s.name
WHERE cr.id = 483368
本质上,我需要返回以可用字段start
年份作为值的教练,我曾经只提取年份,问题是该查询不返回任何记录。name
competition_season
SUBSTR
解决方案
如果两者都是字符串值,
SUBSTR(cr.start, 1, 4) 等于“2017”。
s.name = "2017/2018"。
2 个值不相等。
推荐阅读
- mysql - 如何从一张表中只插入一列到多列表中?
- python - 从python中的方法返回一个值
- hyperledger-fabric - 如何在超级账本作曲家中自动增加资产 ID?
- python - 在python中删除CSV文件的特定行
- asp.net - ASP.Net Core MVC asp-validation-summary 样式
- c# - 如何用 c# 替换 JPanel
- python - 将文件一一传递给python脚本(Windows上的XARGS?FORFILES?)
- c++ - 正确使用在头文件中声明对象
- r - 识别与 df$columnA 中出现两次的值相对应的行,然后在 df$columnB 中分配一个值
- c++ - std::disjunction 中的短路模板特化