我的SQL有问题。 我有一个名为tblseaexport的表,列有ShipmentID,备注。备注列使用TEXT属性设置。如果我有样本数据:
ShipmentID Remarks
S000123 Advised Shipper
S000124 2014-01-24
S000125 2014-01-25
如何在SQL中选择备注值为日期格式的所有行?
答案 0 :(得分:2)
你可以使用类似的东西:
select t.*
from t
where Remarks regexp '^[0-9]{4}-[0-9]{2}-[0-9]{2}$'
答案 1 :(得分:2)
试试这个
select date_format(Date(Remarks),'%Y-%m-%d') from table1
where STR_TO_DATE(Remarks,'%Y-%m-%d') IS NOT NULL