码迷,mamicode.com
首页 > 数据库 > 详细

postgresql inner join

时间:2017-08-12 14:04:49      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:style   sel   select   ctc   post   postgres   outer   6.4   color   

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

标签:style   sel   select   ctc   post   postgres   outer   6.4   color   

原文地址:http://www.cnblogs.com/cdyboke/p/7349883.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!