I tried it but no luck,I have two tables "crm_rentals" and "crm_sales".
Both have same structure.
Id | portals_name
1 | {dubizzle}{JustRentals}{JustProperty}{propertyfinder}{bayut}
2 | {dubizzle}{JustRentals}{JustProperty}{propertyfinder}{bayut}
3 | {JustRentals}{JustProperty}{propertyfinder}
4 | {dubizzle}{JustProperty}{bayut}
I want to get NUMBER of each portal in both tables,here is what i tried
select sum(dubizzle) dubizzle,sum(JustRentals) JustRentals,
sum(JustProperty) JustProperty,sum(propertyfinder) propertyfinder
from ( (select count(id) as dubizzle from crm_rentals where
portals_name like '%dubizzle%'
UNION
select count(id) as dubizzle from crm_sales where portals_name
like '%dubizzle%'
) a ,
(select count(id) as JustRentals from crm_rentals where
portals_name like '%JustRentals%'
UNION
select count(id) as JustRentals from crm_sales where
portals_name like '%JustRentals%') b,
(select count(id) as JustProperty from crm_rentals where
portals_name like '%JustProperty%'
UNION
select count(id) as JustProperty from crm_sales where portals_name
like '%JustProperty%') c ,
(select count(id) as propertyfinder from crm_rentals where
portals_name like '%propertyfinder%'
UNION
select count(id) as propertyfinder from crm_rentals where
portals_name like '%propertyfinder%'
) d )
I want to get result like
Dubizzle JustRentals JustProperty Propertyfinder Others
100 100 100 100 100
Question: I can not get this result,my query give me Syntax error.
UPDATE I tried this but syntax error
select * from (select @table1:=(select count(id) as dubizzle
from crm_rentals where portals_name like '%dubizzle%') a,
@table2:=(select count(id) as dubizzle from crm_sales
where portals_name like '%dubizzle%') b, (@table1 +@table2)
as dubizzle) f,
((select @table1:=(select count(id) as JustRentals from
crm_rentals where portals_name like '%JustRentals%') c,
@table2:=(select count(id) as JustRentals from crm_sales
where portals_name like '%JustRentals%') d, (@table1 +@table2)
as JustRentals) ff) AS f