mysql - Operand should contain 1 column(s) when selecting data from another table AS value -
can 1 please me here, ive googled, , looked @ other examples error confuses me , cant seem head around this.
im struggling selecting data else in mysql query im getting following error...
operand should contain 1 column(s) what simplified term operand?
below mysql query...
select atable_garage.id, atable_garage.total_votes num_votes, atable_garage.name, atable_garage.address, atable_garage.city, atable_garage.postcode, atable_garage.main_dealer, atable_garage.phone, atable_garage.website, atable_garage.description, atable_garage.years_in_business, atable_garage.garage_image, (select(avg(quality_of_repair) + avg(attitude_of_staff) + avg(overall_satisfaction))/3 rating, count(*) num_votes atable_feedback validated = 'y' , atable_garage.id = garage_id) `atable_garage` valeting = 'y' , active = 'y' order rating desc, atable_garage.total_votes desc can point out i've done wrong here? , if possible explain i'm finding difficult head around 1 in advance.
the correlated subquery can return 1 column @ time. since want have 2 column, can restrusture query converting left join.
select atable_garage.id, atable_garage.total_votes num_votes, atable_garage.name, atable_garage.address, atable_garage.city, atable_garage.postcode, atable_garage.main_dealer, atable_garage.phone, atable_garage.website, atable_garage.description, atable_garage.years_in_business, atable_garage.garage_image, coalesce(b.rating, 0) rating, coalesce(b.num_votes, 0) num_votes atable_garage left join ( select garage_id, (avg(quality_of_repair) + avg(attitude_of_staff) + avg(overall_satisfaction)) / 3.0 rating, count(*) num_votes atable_feedback validated = 'y' group garage_id ) b on atable_garage.id = b.garage_id valeting = 'y' , active = 'y' order rating desc, atable_garage.total_votes desc
Comments
Post a Comment