mysql count select 子查询:
select count(*) from (select c.id from ads_travel.ads_deal_flight df join ads_travel.ads_catalog c
on df.catalog_id=c.id and c.category_id=3
where departure like '%上海%'
and destination like '%深圳%'
and departure_time like '%2012-11-30%'
group by c.id) t;
对应hibernate子查询
select count(*) from Catalog c where c.id in (select df.catalog.id from DealFlight df where df.departure like :departure and df.destination like :destination and df.departureTime like :departureTime and df.catalog.category.id=:category_id group by df.catalog.id)
select count(*) from (select c.id from ads_travel.ads_deal_flight df join ads_travel.ads_catalog c
on df.catalog_id=c.id and c.category_id=3
where departure like '%上海%'
and destination like '%深圳%'
and departure_time like '%2012-11-30%'
group by c.id) t;
对应hibernate子查询
select count(*) from Catalog c where c.id in (select df.catalog.id from DealFlight df where df.departure like :departure and df.destination like :destination and df.departureTime like :departureTime and df.catalog.category.id=:category_id group by df.catalog.id)