我正在製作以下格式的用戶狀態列表「A like B's XXX」。 A和B都是註冊用戶,具有姓和名和用戶標識。如何兩次將狀態表與用戶表連接以獲取這兩個用戶的名稱?謝謝。SQL連接多次?
SELECT "SQACTION"."TIMECREATED",
"SQWORDLIST".*,
"SUBJECT"."FIRSTNAME" subject_fn,
"SUBJECT"."LASTNAME" subject_ln,
author.firstname author_fn,
author.lastname author_ln
FROM "SQACTION"
INNER JOIN "SQWORDLIST"
ON SQACTION.ACTION = SQWORDLIST.GUID
INNER JOIN "SQUSER" SUBJECT
ON SQACTION.SUBJECT = SUBJECT.GUID
LEFT JOIN SQDOCUMENT
ON SQACTION.ENTITY = SQDOCUMENT.GUID
LEFT JOIN SQUSER AUTHOR
ON SQDOCUMENT.AUTHORID = AUTHOR.GUID
WHERE (SUBJECT.GUID = 'B4D3BF632C0C4DB3AB01C8B284069D8F')
OR (SUBJECT.GUID IN ('67882AF3FA3C4254AF9A12CA0B0AB6E4',
'6A4B52FE233444838AACFE2AFFE4D38F',
'8CA3FB9061FF4710B51F1E398D3D1917'))
ORDER BY "TIMECREATED" DESC
這就是我試過的。謝謝。
嗨,我想做一個主題動詞對象格式狀態。該主題是一個用戶,該對象可以是用戶本身或用戶的東西。 – Yangrui 2012-08-04 05:26:21
我將用戶名和用戶的東西存儲在兩張獨立的表上。該ID是全球性的。 – Yangrui 2012-08-04 05:27:23
狀態與用戶a和用戶之間的關係是什麼? – 2012-08-04 07:00:48