Table articles stores articles id ant title values. Table similar adds extra articles with similar_id by matching article = similar table ID.
I’d better show output, its very hard to explain in words:
Article with id 3 -> Title3 Text3
when
Similar articles -> Title1(voteup,votedown), Title2(voteup,votedown)
because article table id = similar table id. ( 3 = 3[similar_id 1],3[similar_id 2]. )
And probably when article outputs similar articles id it has to back and take title of similar_id from first table.
–
Table Articles:
ID Title text
1 title1 text1
2 title2 text2
3 title3 text3
Table Similar:
ID Similar_ID voteup votedown
1 2 50 2
2 3 1621 531
3 1 ... ...
3 2 ... ...
Based on your requirements, the
Similar_IDfield is a red herring here and shouldn’t be included in the query:And to include similar titles (although I’m not quite sure how you want the data structured), you can do this: