Two LEFT – RIGHT JOIN in Select Statements

Here is an example of RIGHT JOIN:

mysql> SELECT ArticleTitle, Copyright, CONCAT_WS(' ', AuthorFirstName, AuthorMiddleName, AuthorLastName) AS Author
-> FROM Articles AS b RIGHT JOIN AuthorArticle AS ab ON b.ArticleID=ab.ArticleID
->    RIGHT JOIN Authors AS a ON ab.AuthID=a.AuthID
-> ORDER BY ArticleTitle;

Here is an example of LEFT JOIN:

mysql> SELECT ArticleTitle, Copyright, AuthID
-> FROM Articles AS b LEFT JOIN AuthorArticle AS ab
->    ON b.ArticleID=ab.ArticleID
-> ORDER BY ArticleTitle;

‘USING’ command in LEFT JOIN:

mysql> SELECT ArticleTitle, Copyright, AuthID
-> FROM Articles LEFT JOIN AuthorArticle
->    USING (ArticleID)
-> ORDER BY ArticleTitle;

Two LEFT JOIN in select command:

mysql> SELECT ArticleTitle, Copyright, CONCAT_WS(' ', AuthorFirstName, AuthorMid
dleName, AuthorLastName) AS Author
-> FROM Articles AS b LEFT JOIN AuthorArticle AS ab ON b.ArticleID=ab.ArticleID
->    LEFT JOIN Authors AS a ON ab.AuthID=a.AuthID
-> ORDER BY ArticleTitle;

Two LEFT JOIN:

mysql> SELECT ArticleTitle, Copyright, AuthorFirstName, AuthorMiddleName, AuthorLastName
-> FROM Articles AS b LEFT JOIN AuthorArticle AS ab ON b.ArticleID=ab.ArticleID
->    LEFT JOIN Authors AS a ON ab.AuthID=a.AuthID
-> ORDER BY ArticleTitle;

About onlinejt

Blogger

,

No comments yet.

Leave a Reply

*