我正在尝试将存储在 mysql 数据库中的日期转换为 VARCHAR(格式示例:2012 年 12 月 29 日),然后我想按它排序,以便旧日期在最前面,然后是当前日期。
Eg:
11-01-2012
11-05-2012
12-25-2012
...
这是我到目前为止所拥有的,(请帮助!!谢谢)
<?php
$listsql = "SELECT contact.id, CONCAT(lastname,', ',firstname) AS fullname, lastname, firstname,
STR_TO_DATE(daDATE,'%m-%d-%Y'), line1, line2, city, state, zip, phone1, phone2, country, whoAdded
FROM ". TABLE_CONTACT ." AS contact
LEFT JOIN ". TABLE_ADDRESS. " AS address ON contact.id=address.id AND contact.primaryAddType=address.type
LEFT JOIN ". TABLE_EMAIL ." AS email ON contact.id=email.id AND contact.primaryAddType=email.type
WHERE contact.hidden != 1
ORDER BY email.daDATE";
?>