Вот мой запрос:
SELECT *
FROM comments
INNER JOIN posts ON 'comments.postPostId' = 'posts.post_id';
Все комментарии:
blog=# select * from comments;
comment_id | uid | content | postPostId
--------------------------------------+--------------------------------------+-------------------------+--------------------------------------
49104d66-aebf-48f5-b816-46d9def8edc2 | 5ef3d422-8b98-4509-a752-5ac8d1aee40d | oh man this game is lit | 1c756322-0042-4d8e-bab8-e04a9ceb981e
(1 row)
Все сообщения:
blog=# select * from posts;
post_id | uid | title | sub_title | content | userUserId
--------------------------------------+--------------------------------------+-------+----------------+---------+--------------------------------------
1c756322-0042-4d8e-bab8-e04a9ceb981e | 2e83d249-7c7c-43c0-8e3d-854ddac7c1b8 | bf1 | love this game | bla bla | 6cc903a7-11bf-43a4-a75a-3e1456404525
(1 row)
результат:
blog=# SELECT * FROM comments INNER JOIN posts ON 'comments.postPostId' = 'posts.post_id';
comment_id | uid | content | postPostId | post_id | uid | title | sub_title | content | userUserId
------------+-----+---------+------------+---------+-----+-------+-----------+---------+------------
(0 rows)
Почему это пустой набор? Разве я не должен технически получить 1 строку назад?
РЕДАКТИРОВАТЬ:
Без использования одинарных кавычек (как предложено), я получаю эту ошибку:
ERROR: column comments.postpostid does not exist
LINE 1: SELECT * FROM comments INNER JOIN posts ON comments.postPost...
^
HINT: Perhaps you meant to reference the column "comments.postPostId".