postgresql inner join

Posted dy blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了postgresql inner join相关的知识,希望对你有一定的参考价值。

test=> select * from favoriteguidance 
test-> ;
  userid   |          createtime           |       objectcreatetime        |   title   | objectid  
-----------+-------------------------------+-------------------------------+-----------+-----------
 100000004 | 2017-08-07 00:27:26.452547-04 | 2017-08-07 00:27:26.158434-04 | 校园导航  | 100000013
 100000004 | 2017-08-07 00:27:26.606016-04 | 2017-08-07 00:27:26.606016-04 | guidance |         1
 100000004 | 2017-08-07 00:27:26.606016-04 | 2017-08-07 00:27:26.606016-04 | guidance |         2
 100000071 | 2017-08-09 00:46:08.093299-04 | 2017-08-06 22:53:44.729831-04 | 校园导航1 |         1
         3 | 2017-08-09 22:27:13.823857-04 | 2017-08-06 22:53:44.729831-04 | 校园导航1 |         1
         1 | 2017-08-10 11:50:52.847896-04 | 2017-08-06 22:53:44.729831-04 | 校园导航1 |         1
(6 rows)

test=> select favorite.objectID "id" from favoriteGuidance favorite left outer join guidance data on (favorite.objectID = data.id and
test(> favorite.userID = 100000004);
    id     
-----------
 100000013
         1
         2
         1
         1
         1
(6 rows)
test=> select favorite.objectID "id" from favoriteGuidance favorite left outer join guidance data on (favorite.objectID = data.id) where favorite.userID = 100000004;
    id     
-----------
 100000013
         1
         2
(3 rows)

 

以上是关于postgresql inner join的主要内容,如果未能解决你的问题,请参考以下文章

Postgresql中的Inner Join子查询导致错误

使用 INNER JOIN LATERAL 和 postgresql 将宽表转换为长表

DISTINCT INNER JOIN 慢

LEFT OUTER JOIN with 'field IS NULL' in WHERE 用作 INNER JOIN

我可以保持 INNER JOIN 的输出根据左侧表(第一个表)的顺序进行排序吗?

为啥 data.table 的 inner_join 行为不同?