Forum Moderators: open

Message Too Old, No Replies

SQL Join Help

         

yllw98stng

5:41 pm on Dec 12, 2006 (gmt 0)

10+ Year Member



I have the following SQL Query:

SELECT
'ID' AS "Record Type",
"CSL_STD_DEMO_DISTRICT"."ID_SET_SCHOOL_NAME" AS "Current School Code",
"CSL_STD_DEMO_SCHOOL"."HomeSchDistrict" AS "Resident District Code",
"CSL_STD_DEMO_DISTRICT"."LAST_NAME",
From CSL_STD_DEMO_DISTRICT
LEFT join CSL_STD_DEMO_SCHOOL ON CSL_STD_DEMO_DISTRICT.ID_STD_DEMO_DISTRICT = CSL_STD_DEMO_SCHOOL.ID_STD_DEMO_DISTRICT

where GRADE_DESC!= 'Graduated' AND "CSL_STD_DEMO_DISTRICT"."ID_SET_SCHOOL_NAME" = '5008' AND CSL_STD_DEMO_SCHOOL.ACTIVE_STATUS='Y'

There is a 3rd table I would like to Join to this queary. The table is called CDM_SET_HOMESCHDISTRICT. In the 4th line of my query above, I would like to display the CDM_SET_HOMESCHDISTRICT.HOMESCHDISTRICT_CODE instead of HOMESCHDISTRICT based on:

"CSL_STD_DEMO_SCHOOL"."HomeSchDistrict" = " "CDM_SET_HomeSchDistrict"."ID_SET_HOMESCHDISTRICT"

CDM_SET_HOMESCHDISTRICT contains a column called HOMESCHDISTRICT_CODE that I would like returned instead of "CSL_STD_DEMO_SCHOOL"."HomeSchDistrict"

Hopefully this makes sense and someone will be able to offer some guidance on this.

yllw98stng

2:14 pm on Dec 13, 2006 (gmt 0)

10+ Year Member



Problem was solved by adding third table in the FROM clause and adding an = statement to the WHERE clause.