我有两个日期列from
和to
我想查询
SELECT cast(E.From as varchar(20)) + ' to ' + cast(E.To as varchar(20)) DateRange,
E.Reason, L.Title as LeaveType
FROM employeeleave E
LEFT JOIN listitems L ON E.LeaveTypeID = L.ListItemID
并制作新列daterange
。
我的查询无效。
如何在mysql中将日期值转换为varchar。
答案 0 :(得分:1)
我想你需要concat
SELECT concat(E.From,' to ',E.To) DateRange,
E.Reason,
L.Title as LeaveType
from employeeleave E
LEFT JOIN listitems L ON E.LeaveTypeID = L.ListItemID