0
對於給定的prcs_id,prcs_run_id,multicast_id,我需要multicast_message_recovery_processed中的端點不在multicast_endpoints表的端點列表中的消息的消息ID和端點。SQL中的新手。獲取消息和未處理的端點
數據 -
multicast_endpoints
prcs_id prcs_run_id multicast_id endpoint_id
100 1 multiX destA
100 1 multiX destB
100 1 multiX destC
100 1 multiX destD
100 1 multiY destX
100 1 multiY destY
multicast_message_recovery_processed
prcs_id prcs_run_id multicast_id message_id endpoint_id
100 1 multiX 1 destA
100 1 multiX 2 destB
100 1 multiX 1 destC
100 1 multiY 1 destX
對於給定的prcs_id = 100, prcs_run_id = 1, multicast_id = multiX
,查詢應該返回:
1 destB
1 destD
2 destA
2 destC
2 destD
這基本上意味着,消息1還沒有達到destB
和destD
而消息2未達到destA
,destC
和destD
。
CREATE TABLE multicast_message_recovery_processed
(
prcs_id character varying NOT NULL,
prcs_run_id bigint NOT NULL,
multicast_id character varying NOT NULL,
message_id bigint,
endpoint_id character varying NOT NULL,
CONSTRAINT multicast_message_recovery_processed_pkey PRIMARY KEY (prcs_id , prcs_run_id , multicast_id , endpoint_id)
)
CREATE TABLE multicast_endpoints
(
prcs_id character varying NOT NULL,
prcs_run_id bigint NOT NULL,
multicast_id character varying NOT NULL,
endpoint_id character varying NOT NULL,
CONSTRAINT multicast_endpoints_pkey PRIMARY KEY (prcs_id , prcs_run_id , multicast_id , endpoint_id)
)
感謝Bassam。你能幫我理解查詢嗎?首先,爲什麼需要嵌套塊中的交叉連接? – Narita 2011-12-16 05:08:33