21,891
社区成员
发帖
与我相关
我的任务
分享

$result=mysql_query("SELECT distinct daima, id FROM db WHERE id='$id'");
while($row=mysql_fetch_array($result)){
echo $row["case_id"]."<br />";
}
$result=mysql_query("SELECT distinct daima, id, start_time FROM db WHERE id='$id'");
while($row=mysql_fetch_array($result)){
echo $row["start_time"]."<br />";
}


$result=mysql_query("SELECT bh, max(sj) as sj FROM ttime GROUP BY bh");
while($row=mysql_fetch_array($result)){
echo $row["sj"]." <br />";
}
这样也行
$result=mysql_query("SELECT bh, max(sj) FROM ttime GROUP BY bh");
while($row=mysql_fetch_row($result)){
echo $row[1]." <br />";
试试
--测试代码
use
SQL_Test
go
create table ttime(
bh varchar(200) not null,
sj datetime
)
insert into ttime
select '2009111601','2009-11-16 15:01:46'
union all
select '2009111601','2009-11-16 15:02:46'
union all
select '2009111601','2009-11-16 15:03:46'
union all
select '2009111601','2009-11-16 15:04:46'
union all
select '2009111602','2009-11-16 15:05:46'
union all
select '2009111602','2009-11-16 15:07:46'
--查询
select bh,max(sj) from ttime group by bh
--结果
2009111601 2009-11-16 15:04:46.000
2009111602 2009-11-16 15:07:46.000

select bh,max(UNIX_TIMESTAMP(sj)) from tt group by bh