这是我的SQL查询:
SELECT * FROM
(SELECT * FROM ClassifiedAd
WHERE city_id = :city
AND currency = :currency
AND price > 100)
UNION DISTINCT
(SELECT c.* FROM
ClassifiedAd c
WHERE c.city_id = :city
AND c.currency = :currency
AND (c.price > 100 AND c.price < c.price_last))"
) l,
ClassifiedAd a
LEFT JOIN Picture p ON a.id=p.classifiedAd_id
LEFT JOIN Business b ON b.id=a.business_id
WHERE a.id = l.id
AND (a.price between :priceDown AND :priceUp)
AND a.subCategory_id IN (:apartamentList)
AND a.category_id = :category
AND a.district_id = :district
AND a.datePosted > :date
AND b.status = :bStatus AND a.adStatus = :cStatus AND (b.premium OR b.businessPlus OR b.excellence )
ORDER BY -a.business_id DESC LIMIT :limit
我正在使用mysql和jdbcTemplate。 有一些方法可以使这个查询更快? 我感谢任何帮助。