sql - MySQL CASE QUERY with INNER JOIN -


i have 1 table string type. (photo_add, photo_comment etc.) have 4 other tables connected these types.

i need make query choose data these tables according type.

i created not work.

select distinct a.id, a.event, a.params, a.created_at, a.item_id, a.sender_id, a.receiver_id, u.name, u.id userid  `eva49_lovefactory_activity` a, eva49_users u  case a.event    when "photo_add"      inner join eva49_lovefactory_photos lp on lp.id = a.item_id , lp.fsk18 = -1   when "group_create"       inner join eva49_lovefactory_groups lg on lg.id = a.item_id , lg.fsk18 = -1    when "photo_comment"       inner join eva49_lovefactory_item_comments lic on lic.item_id = a.item_id , lic.fsk18 = -1    when "profile_comment"       inner join eva49_lovefactory_item_comments lic on lic.item_id = a.item_id , lic.fsk18 = -1    when "profile_comment"      inner join eva49_lovefactory_profiles lp on lp.user_id = a.receiver_id , lp.status_fsk18 = -1    else 1=1  end  (u.id = a.sender_id or u.id = a.receiver_id) , (u.id <> 379)  order a.created_at desc limit 0, 10 

is there way how pair tables? database structure given me this.

edit:

there table "eva49_lovefactory_activity" contains information recent activity. has column "event" contains string event name (photo_add, photo_comment etc.)

there other tables - eva49_lovefactory_photos, eva49_lovefactory_profiles, eva49_lovefactory_groups etc. in these tables have find whether item approved admin. if can show it. (fsk18 = -1)

move case condition join condition , left join..

select distinct a.id, a.event, a.params, a.created_at, a.item_id, a.sender_id, a.receiver_id, u.name, u.id userid  `eva49_lovefactory_activity` a, eva49_users u       left join eva49_lovefactory_photos lp on lp.id = a.item_id , lp.fsk18 = -1                , a.event='photo_add'     left join eva49_lovefactory_groups lg on lg.id = a.item_id , lg.fsk18 = -1                 , a.event='group_create'     left join eva49_lovefactory_item_comments lic on lic.item_id = a.item_id ,                lic.fsk18 = -1     , a.event='photo_comment'     left join eva49_lovefactory_item_comments lic on lic.item_id = a.item_id ,                lic.fsk18 = -1     ,   a.event='profile_comment'  (u.id = a.sender_id or u.id = a.receiver_id) , (u.id <> 379)  order a.created_at desc limit 0, 10 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -