我有两张表有列表图片。我想获得少于三张图片的列表数量。这是我的查询,但它无法正常工作。
select
@table1_pic:=(select
count(i.id)
from
crm_rentals_images as i,
crm_rentals as r
where
r.id = i.rentals_id and r.status = 2
and r.is_archive = 0
and r.is_active = 1
group by i.rentals_id
HAVING COUNT(*) < 3) as pic_rentals,
@table2_pic:=(select
count(i.id)
from
crm_sales_images as i,
crm_sales as r
where
r.id = i.rentals_id and r.status = 2
and r.is_archive = 0
and r.is_active = 1
group by i.rentals_id
HAVING COUNT(*) < 3) as ppic_sales,
(@table1_pic + @table2_pic) as tot_img
这给我错误
Subquery returns more than 1 row
注意:我想得到每个的总数,然后是两者的总和