日期时间转换存在问题,目前“xl_date”的日期为MM / DD / YYYY
示例查询: -
SELECT orders.*,
customer.id AS userid,
customer.login,
convert(datetime, orders.xl_date, 101) as ddates
FROM orders
LEFT JOIN customer
ON orders.userid = customers.id
WHERE 1
ORDER BY ddates DESC LIMIT 0, 30
答案 0 :(得分:0)
您需要使用STR_TO_DATE功能。例如 -
SELECT STR_TO_DATE(orders.xl_date, '%m/%d/%Y') AS as ddates FROM orders
您的查询是 -
SELECT
orders.*,
customer.id AS userid,
customer.login,
STR_TO_DATE(orders.xl_date, '%m/%d/%Y')as ddates
FROM orders
LEFT JOIN customer
ON orders.userid = customers.id
WHERE
1
ORDER BY
ddates DESC
LIMIT 0, 30