--1 select * from tb where city = '592' union all select * from tb where city <> '592'--2 select * from tb order by case city when '592' then 1 else 2 end
select * from tb where city = '592' union all select * from tb where city <> '592'可实现但如用hibernate就不行了,用hibernate要怎样查询呢
public List<KtvInfo> getRingbycity1(String city){ System.out.print("====civvty==="+city); List<KtvInfo> l =ktvInfoDao.find("from KtvInfo where city='592' union all from KtvInfo where city<>'592' ", null); if(l.size()>0) return l; else return null; }用上面的hibernate只能查询出from KtvInfo where city='592'
find("from KtvInfo order by case when city = '592' then 0 else 1 end",null);
--1
select * from tb where city = '592'
union all
select * from tb where city <> '592'--2
select * from tb order by case city when '592' then 1 else 2 end
union all
select * from tb where city <> '592'可实现但如用hibernate就不行了,用hibernate要怎样查询呢
System.out.print("====civvty==="+city);
List<KtvInfo> l =ktvInfoDao.find("from KtvInfo where city='592' union all from KtvInfo where city<>'592' ", null);
if(l.size()>0)
return l;
else
return null;
}用上面的hibernate只能查询出from KtvInfo where city='592'