首页 > 代码库 > postgresql inner join

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 andtest(> 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