Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I think Inner Join problem 1

Status
Not open for further replies.

shauns1

Programmer
Oct 21, 2005
53
AU
I am Selecting all of the rows from a main table (cms_WhatsHot) along with related rows from other tables (cms_Segments and cms_SegmentsParents) all joined using Inner join. The main table (cms_WhatsHot) will always have rows, the joined tables may have no related rows. The result is that if a related row is empty it doesn't return the row from the main table at all.

This is my SQL:

SELECT cms_WhatsHot.whatsHotID, ISNULL(cms_WhatsHot.whatsHotTitle, '') AS whatsHotTitle, ISNULL(cms_WhatsHot.whatsHotDescription, '')
AS whatsHotDescription, ISNULL(cms_WhatsHot.whatsHotSegmentID, '0') AS whatsHotSegmentID, ISNULL(cms_WhatsHot.whatsHotExternalURL, '')
AS whatsHotExternalURL, ISNULL(cms_WhatsHot.whatsHotExternalURLImage, '') AS whatsHotExternalURLImage,
ISNULL(cms_Segments.segmentParentID, '0') AS segmentParentID, ISNULL(cms_Segments.segmentTitle, '') AS segmentTitle,
ISNULL(cms_Segments.segmentImageFile, '') AS segmentImageFile, ISNULL(cms_SegmentParents.parentTemplateURL, '') AS parentTemplateURL
FROM cms_WhatsHot INNER JOIN
cms_Segments ON cms_WhatsHot.whatsHotSegmentID = cms_Segments.segmentID INNER JOIN
cms_SegmentParents ON cms_Segments.segmentParentID = cms_SegmentParents.parentID
ORDER BY cms_WhatsHot.whatsHotOrderID

Should I be using InnerJoin or am I on the wrong track?

Thanks for any help in advance.

s
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top