1
我有以下SQL查詢區分SQL的結果右連接
SELECT `User`.`username` , Permalink.perma_link_id, Permalink.locale,
Permalink.title, DATEDIFF(CURDATE() , Permalink.created) AS dtdiff,
`TargetSegment`.segment_text, TargetSegment.source_segment_id,
TargetSegment.perma_link_id ,TargetSegment.created ,
TargetSegment.updated, DATEDIFF(CURDATE() ,
TargetSegment.updated) AS datediff
FROM `users` AS `User`
RIGHT JOIN perma_links AS `PermaLink`
ON (`PermaLink`.`username` = `User`.`username`)
RIGHT JOIN target_segments AS `TargetSegment`
ON (`TargetSegment`.`username` = `User`.`username`)
RIGHT JOIN source_segments AS `SourceSegment`
ON (`SourceSegment`.`source_detail_id` = `PermaLink`.`source_detail_id`)
LEFT JOIN source_details AS `SourceDetail`
ON (`SourceSegment`.`source_detail_id` = `SourceDetail`.`id`)
WHERE `TargetSegment`.`username` = "xxxx"
AND `TargetSegment`.`segment_text` <> ""
AND `Permalink`.`perma_link_id` = `TargetSegment`.`perma_link_id`
AND `TargetSegment`.`source_segment_id` = `SourceSegment`.`id`
AND `Permalink`.`source_detail_id` = `SourceDetail`.`id`
ORDER BY `TargetSegment`.`updated` DESC
LIMIT 0 , 10
這個SQL是獲取正確的結果對於我,我想從哪個表的每一行,以確定是否從,具體哪些結果是由於到PermaLink表,它來自TargetSegment表。
這是可以實現的嗎?
我可以用聯盟使用不同表格行的標識符獲得相同的結果? – Sourabh 2010-06-11 09:04:00