我正在尝试更改此查询,以便按日期正确排序。
此行有效,但未按顺序排列所有日期。按年份排序,而不是按日期和月份排序。
$query = mysql_query
("SELECT `date` FROM `table` WHERE `day` LIKE '%$row->period$row->friday%' AND date != '' ORDER BY `date` DESC LIMIT 1");
while($row2 = mysql_fetch_object($query)){
echo $row->date;
我创建了这个,但回声保持空白。我做错了什么?
$query = mysql_query
("SELECT DATE_FORMAT(date, '%d-%m-%Y') as `date2` FROM `table` WHERE `day` LIKE '%$row->period$row->friday%' AND date != '' ORDER BY `date` ASC LIMIT 1");
while($row = mysql_fetch_object($query)){
echo $row->date2;
答案 0 :(得分:0)
语法错误。
SELECT `date` FROM `table`
WHERE `day` LIKE '%".$row->period."%'
OR day like '%".$row->period."%' AND date != '' ORDER BY `date` DESC LIMIT 1")