I have the following Stored Procedure below that is not working to my needs and need some help. I have attached an Excel file that has data for the two tables that I'm working with.
I need to see the following fields below based on two values shown below.
Note: the value ghaocp_id may be NULL or = 0 in some situations. Also, all ghaocp_id values are all related to a particualar ghaoc_id value.
Fields to display:
ghaco_name --> From HealthCourses_GeneralHealt
ghaocp_name --> From HealthCourses_GeneralHealt
ALTER PROCEDURE [dbo].[HealthCourses_RetrieveRegisterCourseInfo]
SELECT oc.ghaoc_id, oc.ghaco_name, ocp.ghaocp_id, ocp.ghaocp_name
FROM dbo.HealthCourses_GeneralHealthAwarenessOneCourses AS oc
INNER JOIN dbo.HealthCourses_GeneralHealthAwarenessOneCoursesPrograms AS ocp
ON oc.ghaoc_id = ocp.ghaoc_id
WHERE oc.ghaoc_id = @ghaoc_id