Mysql 列出“;经典汽车&x201D;1960年至2019年的产品线;s
这个问题的难点在于没有真实的日期,我应该从“1960福特”这样的描述中提取日期 我尝试过使用子字符串,但没有成功。 这是我使用的查询Mysql 列出“;经典汽车&x201D;1960年至2019年的产品线;s,mysql,sql,subquery,Mysql,Sql,Subquery,这个问题的难点在于没有真实的日期,我应该从“1960福特”这样的描述中提取日期 我尝试过使用子字符串,但没有成功。 这是我使用的查询 Select productlines from products where productsline= "Classic cars" and substring('productname', 1, 4) =>1960 and substring('productname', 1, 4)>=1970 您已经完成了正确的查询,但只需要从子字符串函数
Select productlines
from products
where productsline= "Classic cars"
and substring('productname', 1, 4) =>1960 and substring('productname', 1, 4)>=1970
您已经完成了正确的
查询
,但只需要从子字符串函数中删除“
符号,因为列名不应在字符串中定义
如果您仍然面临困难,请告诉我。请尝试以下SQL查询:
Select productlines
from products
where productsline= "Classic cars"
and CAST(substring('productname', 1, 4) as SIGNED) =>1960 and CAST(substring('productname', 1, 4) as SIGNED)>=1970
和'productname`REGEXP.*196[0-9].*$'
@Sik2。在'productname'
周围有单引号,因此这是一个字符串,而不是列引用。我投票以打字错误结束。删除查询有效,但我无法指定范围,代码仅适用于1969年这样的一年。您能帮我指定=>1960年这样的范围吗=