Answered
Query Problem
I am using the following query in my cfform action page :
<cfquery name="qry" datasource="dsname">
select
Detail.user_employee_number,
Detail.user_status,
Detail.role_id,
Master.role_id,
Master.role,
Master.region,
Master.site
from Master left join Detail
on Master.role_id = Detail.role_id
where Detail.user_employee_number = '#url.user_employee_number#'
order by role,region,site,user_status
</cfquery>
I want to find all master records regardless of a match. If there are ten master records and only five detail records, I want all ten master records to be retrieved and displayed. What I am getting is only two records, which is the two matches that are found.
I always though left join would accomplish this, but I guess not. What am I doing wrong and what is the proper sql to do what I want to do, with the selection above ?
Thanks
<cfquery name="qry" datasource="dsname">
select
Detail.user_employee_number,
Detail.user_status,
Detail.role_id,
Master.role_id,
Master.role,
Master.region,
Master.site
from Master left join Detail
on Master.role_id = Detail.role_id
where Detail.user_employee_number = '#url.user_employee_number#'
order by role,region,site,user_status
</cfquery>
I want to find all master records regardless of a match. If there are ten master records and only five detail records, I want all ten master records to be retrieved and displayed. What I am getting is only two records, which is the two matches that are found.
I always though left join would accomplish this, but I guess not. What am I doing wrong and what is the proper sql to do what I want to do, with the selection above ?
Thanks