MYSQL query using Left Join and Where IN clause -


i have 3 tables b c , i'm trying retrieve information three.

a has columnns userid avatar username , b has column postid, dateshared , c has column commenter postid datecommented.

i'm trying run query

select  c.comment, c.commenter,  c.datecommented, b.postid, b.dateshared a.username a.avatar b left join c  left join on c.postid = b.postid , a.userid = c.commenter b.postid in ('1','2','3') order  c.dateshared desc 

but gives following error:

 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'where b.postid in ('1', '2', '3') order c.dateshared ' 

can point out i'm doing wrong or suggest how go it?

each left join requires own on condition:

select  c.comment, c.commenter, c.datecommented, b.postid, b.dateshared, a.username a.avatar    b left join         c on      c.postid = b.postid left join         on      a.userid = c.commenter   b.postid in ('1','2','3') order         c.dateshared desc 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -