0

## 子查詢的應用問題-2

select * from public.Bandana where bandanacontext='net.kentcom.PageViewTracker.All.59247661' AND bandanakey='TotalCount'

(參考此篇: https://ithelp.ithome.com.tw/questions/10185737)

``````SELECT TAB2.pageid, TAB1.contentid ,TAB3 spacename
FROM content TAB1,
(SELECT pageid
FROM content
WHERE contentid IN (select 59247661 from public.Bandana where bandanacontext='net.kentcom.PageViewTracker.All.59247661' AND bandanakey='TotalCount'))TAB2,spaces TAB3
WHERE TAB2.pageid =  TAB1.contentid and
TAB1.spaceid = TAB3.spaceid
``````

ektrontek iT邦研究生 1 級 ‧ 2018-01-08 20:16:31 檢舉

SELECT TAB2.pageid, TAB1.title ,TAB3.spacename
FROM content TAB1,
(SELECT pageid FROM content
WHERE pageid IN (select cast(right(bandanacontext,8) as integer) as contentcode from public.Bandana where bandanakey='TotalCount') and pageid is not null) TAB2,spaces TAB3
WHERE TAB2.pageid = TAB1.contentid and TAB1.spaceid = TAB3.spaceid

### 2 個回答

0

iT邦大師 1 級 ‧ 2018-01-08 12:40:42

bandanacontext='net.kentcom.PageViewTracker.All.59247661'

bandanacontext like '%59247661'

ektrontek iT邦研究生 1 級 ‧ 2018-01-08 12:48:02 檢舉

``````59247661
46334060
59246891
47120946
46333982
``````
1
allenlwh
iT邦高手 1 級 ‧ 2018-01-08 13:17:43

``````select right(bandanacontext,8) as contentcode from public.Bandana
``````