php - How to get data from 3 mysql tables? -


i have 3 mysql tables a) contact_details b) history , c) company.

now getting family_name contact_details table based on last 5 view_id history table.

my current query working fine :)

now want company_name data company table company.cid match contact_details.cid. how can following working query ?

working query :

$getviewid2 = mysqli_query($link, "select  cd.family_name, t.* contact_details cd  inner join (     select      history.*     history     inner join      (         select          view_id,         max(view_date) max_view_date         history          is_save in (0,1) , mark_as = 1         group view_id         order max_view_date desc          limit 5     ) latesthistory     on history.view_id = latesthistory.view_id , history.view_date = latesthistory.max_view_date ) t on cd.cdid = t.view_id order cd.family_name asc");   

well bombs if companyid doesn't exist contact details after cd.cdid = t.view_id add

 , company cy company.cid = cd.cid 

and before from add

, cy.* 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -