postgresql inner join
时间:2021-07-01 10:21:17
帮助过:24人阅读
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