Created
February 3, 2017 19:52
-
-
Save kracekumar/eb9f1009743ccb47df2b3a5f078a4444 to your computer and use it in GitHub Desktop.
Inner join with row_to_json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test=# select row_to_json(row) from (select book.id, book.name, book.author_id, author.name as author_name from book inner join author on book.author_id = author.id) row; | |
{"id":1,"name":"War and Peace","author_id":1,"author_name":"Leo Tolstoy"} | |
{"id":2,"name":"The Trial","author_id":2,"author_name":"Kafka"} | |
{"id":3,"name":"The metamorphosis","author_id":2,"author_name":"Kafka"} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment