My sql question neds some change
I have three tables users, bloggposts and comment. The relation between these are
as follows one user can have many bloggposts and one bloggposts can have many comments.
I have included just as much as needed for this question.
This sql query works fine when there is at least one comment on a bloggpost.
But when have no comment I dont get anything from the query
For example bloggid 64 has some comment so this sql query give the result I want
select accountname, title, message from bloggposts, COMMENT,users where bloggposts.id = comment.bloggid AND bloggid=64 and users.id = bloggposts.userid
If I replace 64 with 31 I get
MySQL returnerade ett tomt resultat (dvs inga rader). (Frågan tog 0,0076 sekunder.
I have tried with this but it givs error SELECT accountname,title,message FROM bloggposts
LEFT JOIN users ON bloggposts.id = users.id
left JOIN comment ON bloggposts.bloggid = comment.id
I need the information from both users and bloggposts even when there is no comments
Subject
Written By
Posted
My sql question neds some change
March 16, 2020 09:47AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.