SQL JOIN USING clause with custom projection INNER JOIN post_comment ON post.post_id = post_comment.post_idĪnd, we will get back the following result set: Typically, when writing an INNER JOIN or LEFT JOIN query, we would use the ON clause to define the join condition.įor instance, to get the comments as well as the associated post title and post identifier, we can write the following SQL projection query: SQL JOIN ON clause with custom projection There are the following 3 rows in the parent post table:Īnd the post_comment child table has the following 3 records: To demonstrate how the JOIN USING clause works, we are going to use the following post and post_comment database tables, which form a one-to-many table relationship via the post_id Foreign Key column in the post_comment table that references the post_id Primary Key column in the post table: In this article, we are going to see how the JOIN USING clause works in SQL, and how we can use it to replace the ON condition clause when the columns used to join the two tables have the same name in both the parent and the child tables. Follow you are trading Stocks and Crypto using Revolut, then you are going to love
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |