一、查询表中最小的数据
select id,min(price) from table where id=8 group by price
二、查询指定某数之间
select id,price from table where id=8 and (price between {$sp} and {$ep})
三、多表查询
select hotel.* from hotel,room where hotel.id=room.j_hid order by hotel.id asc
四、查询重复数据且只输出一条
select *,count(distinct hid) from room group by j_hid
五、时间段查询
select * from tablename where date between '{$stime}' and '{$etime}'
六、重复记录查询
//列出所有记录,如有重复的只输出一条
$sql="select *, count(distinct j_name) from table group by j_name";
//只列出重复的数据
$sql='select id,j_name,count(*) from table group by j_name having count(*)>1';
上一篇:PHP浏览frameset框架页面时显示空白解决方法
讨论数量:0