I have the following 2 tables.
tb_Posts
--------
PostId, PostName
tb_PostCategories
------------------
PostId, PostCategoryName
I want to join both these tables, however, I would like to display all columns and entries in tb_Posts but display PostCategoryName column only from tb_PostCategories even if an entry for tb_Posts.PostId in tb_PostCategories exists or not.
So, I did this query, but it I am getting a SQL error
SELECT *
FROM
(SELECT a.PostId, a.PostName from tb_Posts a) y
LEFT JOIN tb_PostCategories z USING (y.PostId)
Thanks
*gets all columns.You can do:
This doesn’t really seem to require a subquery, however, so to simplify a bit: