Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有更好的方法将时间字段格式化为小写 AM 或 PM?这就是我在 SELECT 语句中的内容,它可以工作,但相当笨拙:
CONCAT_WS('', DATE_FORMAT(time, '%l:%i '), LOWER(DATE_FORMAT(`time`, '%p'))) AS time
我想更重要的是,使用这样的 SQL 函数进行格式化是否有任何重大开销?
您可以直接执行此操作而无需连接。
LOWER(DATE_FORMAT(`time`,'%l:%i %p'))
在这里查看@SQLFiddle