aggregate functions - Mysql COUNT sub query -


i have complex query myself across few tables have finished. final aspect involves aggregating how many bids item has received, doing items in particular section though. query works fine except returns 1 row when try , add in aggregation (/* */) query. reading around seem need sub query, except i'm not entirely sure how go this. query date:

select s.id section_id, s.name section, i.id item_id,  i.title item_title, item.location_id item_location_id, i.slug item_slug, i.description item_description,  i.price item_price, unix_timestamp(i.date_added) item_date_added,  c.id, c.city, c.particular_id, p.id, p.particular /*,count(o.i_id) interest*/  section s inner join item on s.id = i.section_id inner join city c on i.location_id = c.id inner join particular p on c.particular_id = p.id  /*left join offer o on o.job_id = i.id*/  s.id = 2 

the code works in returns rows expected until introduction of /* */ code, returns 1 row.

any give me appreciated

thanks

jonny

it should solve problem:

select s.id section_id, s.name section, i.id item_id,      i.title item_title, item.location_id item_location_id,     i.slug item_slug, i.description item_description,      i.price item_price, unix_timestamp(i.date_added) item_date_added,      c.id, c.city, c.particular_id, p.id, p.particular,     (select count(o.i_id) offer o on o.job_id = i.id) interest section s inner join item     on s.id = i.section_id inner join city c     on i.location_id = c.id inner join particular p     on c.particular_id = p.id s.id = 2 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -